-
-
Notifications
You must be signed in to change notification settings - Fork 2k
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
TypeError when updating $session in component constructor #1658
Comments
Was about to write an issue but saw this. It happened on fresh init
Thanks @sfriedel, confirmed also this workaround somehow worked: |
I also have an issue with the same code but I am calling session.set() in a async click event handler after doing a fetch to an endpoint. The setTimeout() workaround did not work for me. App still seems to function fine. |
Posting a link to the reproduction repo here for ease of access: https://github.com/sfriedel/sveltekit-bugreport/tree/typeerror-during-session-hydration |
Describe the bug
If the
$session
store gets written to in the component constructor of a route, sveltekit throws a TypeError at https://github.com/sveltejs/kit/blob/master/packages/kit/src/runtime/client/renderer.js#L115Logs
To Reproduce
src/routes/index.svelte
for the code that triggers the errorExpected behavior
No exception should be thrown
Stacktraces
Stack trace
start.js:448 Uncaught (in promise) TypeError: Cannot read property 'parse' of null
at Array. (start.js:448)
at Object.set (index.mjs?v=93707a36:35)
at set_store_value (index.mjs?v=93707a36:136)
at instance (index.svelte? [sm]:9)
at init (index.mjs?v=93707a36:1485)
at new Routes (index.svelte? [sm]:10)
at createProxiedComponent (svelte-hooks.js:245)
at new ProxyComponent (proxy.js:241)
at new Proxy (proxy.js:341)
at create_if_block_2 (root.svelte? [sm]:38)
Information about your SvelteKit Installation:
Diagnostics
System: OS: Linux 5.8 Ubuntu 20.10 (Groovy Gorilla) CPU: (8) x64 Intel(R) Core(TM) i7-8550U CPU @ 1.80GHz Memory: 1.31 GB / 15.34 GB Container: Yes Shell: 5.8 - /bin/zsh Binaries: Node: 14.17.0 - /usr/bin/node Yarn: 1.22.5 - /usr/bin/yarn npm: 6.14.13 - /usr/bin/npm Watchman: 4.9.0 - /home/sef/.local/opt/watchman/bin/watchman Browsers: Chrome: 90.0.4430.212 Firefox: 89.0 npmPackages: @sveltejs/kit: next => 1.0.0-next.115 svelte: ^3.34.0 => 3.38.2Severity
Low. I have a workaround in place: deferring the store updates with a simple
setTimeout(..., 0)
seems to avoid the issue.The text was updated successfully, but these errors were encountered: