-
-
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
"Function called outside component initialization" when using URQL with SvelteKit production server (dev server works fine) #2397
"Function called outside component initialization" when using URQL with SvelteKit production server (dev server works fine) #2397
Comments
I'm not familiar with urql, but that may be your problem. You are running code on the server. If I set |
@benmccann Thanks for the quick response! Without globally disabling SSR, is there any way around this until URQL supports SSR out-of-the-box? |
You can disable SSR on a per-page basis. Is there any information about why SSR does not work with urql? I wonder if it might be a Vite bug such as vitejs/vite#4306 |
Yeah, so there's been quite a large discussion about it here. The general consensus seems to be that The urql docs suggest that adding |
Dug into this today, the issue is that we add You can observe the behaviour by building the repro repo, and open Workaround
Honestly, I don't think |
svelte/ssr helps to avoid boilerplate code in onMount for SSR with client only dependencies. The fix on vite-plugin-svelte is the way to go 👍 |
Describe the bug
I'm experiencing an interesting bug in which using URQL on the client-side throws a "Function called outside component initialization" error... however, it only happens after building a production build with the Node adapter. If I run my code using the dev environment my site loads fine. I'm curious about the difference between how the two servers are run that could hint as to what is happening here.
I started a discussion over on urql-graphql/urql#1938, but as I'm not sure if the issue lies with SK or URQL, I figured I'd cover both bases. A little bit more context can be found in the linked ticket, but overall, this is the issue I'm facing.
Reproduction
I managed to reproduce the issue in https://github.com/Nickersoft/urql-repro. Just be sure to run yarn first.
Logs
System Info
Severity
blocking all usage of SvelteKit
Additional Information
I'm aware that this topic has been discussed at length in both communities (using URQL with SvelteKit), but in this particular case I'm not attempting to run any code on the server, and am following all of the advice found in various discussions surrounding the use of URQL.
The text was updated successfully, but these errors were encountered: