Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Function called outside component initialization error #59

Closed
stephane-klein opened this issue Jul 17, 2022 · 5 comments
Closed

Function called outside component initialization error #59

stephane-klein opened this issue Jul 17, 2022 · 5 comments

Comments

@stephane-klein
Copy link
Contributor

stephane-klein commented Jul 17, 2022

In this fresh KitDocs project, I have Function called outside component initialization error.

Here is how to reproduce:

$ git clone git@github.com:stephane-klein/kit-docs-playground.git
$ git checkout -b issue 474b05c80e26816a8c69799008abde67bf5e897f
$ cd kit-docs-playground/services/kit-docs
$ pnpm install
$ pnpm run dev

Go to http://127.0.0.1:3000/, I have this error:

$ pnpm run dev                                                                                                                       130

> mydocs@0.0.1 dev /home/stephane/git/github.com/stephane-klein/kit-docs-playground/services/kit-docs
> vite dev


  vite v2.9.14 dev server running at:

  > Local: http://localhost:3000/
  > Network: use `--host` to expose

  ready in 739ms.

Function called outside component initialization
Error: Function called outside component initialization
    at get_current_component (/node_modules/.pnpm/svelte@3.48.0/node_modules/svelte/internal/index.mjs:953:15)
    at Module.setContext (/node_modules/.pnpm/svelte@3.48.0/node_modules/svelte/internal/index.mjs:985:5)
    at root.svelte:15:1
    at $$render (/node_modules/.pnpm/svelte@3.48.0/node_modules/svelte/internal/index.mjs?v=8cb0458f:1755:22)
    at Object.render (/node_modules/.pnpm/svelte@3.48.0/node_modules/svelte/internal/index.mjs?v=8cb0458f:1763:26)
    at render_response (file:///home/stephane/git/github.com/stephane-klein/kit-docs-playground/services/kit-docs/.svelte-kit/runtime/server/index.js:1383:27)
    at async respond$1 (file:///home/stephane/git/github.com/stephane-klein/kit-docs-playground/services/kit-docs/.svelte-kit/runtime/server/index.js:2996:4)
    at async resolve (file:///home/stephane/git/github.com/stephane-klein/kit-docs-playground/services/kit-docs/.svelte-kit/runtime/server/index.js:3346:11)
    at async respond (file:///home/stephane/git/github.com/stephane-klein/kit-docs-playground/services/kit-docs/.svelte-kit/runtime/server/index.js:3290:20)
    at async file:///home/stephane/git/github.com/stephane-klein/kit-docs-playground/services/kit-docs/node_modules/.pnpm/@sveltejs+kit@1.0.0-next.370_svelte@3.48.0+vite@2.9.14/node_modules/@sveltejs/kit/dist/vite.js:2324:22
(node:494086) ExperimentalWarning: buffer.Blob is an experimental feature. This feature could change at any time
(Use `node --trace-warnings ...` to show where the warning was created)
Function called outside component initialization
Error: Function called outside component initialization
    at get_current_component (/node_modules/.pnpm/svelte@3.48.0/node_modules/svelte/internal/index.mjs:953:15)
    at Module.setContext (/node_modules/.pnpm/svelte@3.48.0/node_modules/svelte/internal/index.mjs:985:5)
    at root.svelte:15:1
    at $$render (/node_modules/.pnpm/svelte@3.48.0/node_modules/svelte/internal/index.mjs?v=8cb0458f:1755:22)
    at Object.render (/node_modules/.pnpm/svelte@3.48.0/node_modules/svelte/internal/index.mjs?v=8cb0458f:1763:26)
    at render_response (file:///home/stephane/git/github.com/stephane-klein/kit-docs-playground/services/kit-docs/.svelte-kit/runtime/server/index.js:1383:27)
    at async respond_with_error (file:///home/stephane/git/github.com/stephane-klein/kit-docs-playground/services/kit-docs/.svelte-kit/runtime/server/index.js:2758:10)
    at async respond$1 (file:///home/stephane/git/github.com/stephane-klein/kit-docs-playground/services/kit-docs/.svelte-kit/runtime/server/index.js:3013:4)
    at async resolve (file:///home/stephane/git/github.com/stephane-klein/kit-docs-playground/services/kit-docs/.svelte-kit/runtime/server/index.js:3346:11)
    at async respond (file:///home/stephane/git/github.com/stephane-klein/kit-docs-playground/services/kit-docs/.svelte-kit/runtime/server/index.js:3290:20)

Versions:

$ pnpm list
Legend: production dependency, optional only, dev only

mydocs@0.0.1 /home/stephane/git/github.com/stephane-klein/kit-docs-playground/services/kit-docs

dependencies:
@fontsource/fira-mono 4.5.0
cookie 0.4.1

devDependencies:
@iconify-json/ri 1.1.1                eslint 8.16.0                         shiki 0.10.1
@sveltejs/adapter-auto 1.0.0-next.57  eslint-config-prettier 8.3.0          svelte 3.48.0
@sveltejs/kit 1.0.0-next.370          eslint-plugin-svelte3 4.0.0           unplugin-icons 0.13.4
@svelteness/kit-docs 0.23.0           prettier 2.6.2                        vite 2.9.14
clsx 1.1.1                            prettier-plugin-svelte 2.7.0

Have you an idea to fix this error?

@stephane-klein
Copy link
Contributor Author

I searched on thesvelte-kit Discord channel, I found that many people have this problem since 2022-07-13, I haven't found a solution yet.

@stephane-klein
Copy link
Contributor Author

I see the solution here: https://discord.com/channels/457912077277855764/996789893369970699/996800417004527706

To fix the error, I need to upgrade from @sveltejs/kit 1.0.0-next.370 to @sveltejs/kit 1.0.0-next.371.

@mihar-22 I suggest to upgrade:

I will create a Pull Request.

@stephane-klein
Copy link
Contributor Author

I found SvelteKit upstream issue about this subject: sveltejs/kit#5495

stephane-klein added a commit to stephane-klein/kit-docs that referenced this issue Jul 17, 2022
…teness#59

To fix "Function called outside component initialization error".
SvelteKit issue sveltejs/kit#5495
@stephane-klein
Copy link
Contributor Author

@mihar-22 what do you think about this Pull Request ? #60

@mihar-22
Copy link
Contributor

Should be resolved now on latest.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

2 participants