"Function called outside component initialization" when using SvelteKit production server only (dev server works) #1938
Labels
needs more info ✋
A question or report that needs more info to be addressable
Hey all!
I know SvelteKit support for
@urql/svelte
is kind of iffy at this stage (esp with SSR support) I noticed some odd behavior when trying to just use URQL with client-side Svelte. I'm specifically just using URQL on the client-side, AFAIK (inside a <script> tag, withoutcontext="module"
). This works perfectly when using the dev server, usingsvelte-kit dev
.However, after building a production bundle using the Node adapter and attempting to preview the site, I get hit with a "Function called outside component initialization" error. I'm relatively new to Svelte and am not sure of the differences between how the dev vs. node server are run. Wondering if anyone else has encountered this issue.
Happy to ask the SvelteKit folks as well, but given the relative youth of both URQL and SvelteKit, it's hard for me to say whether this is a bug, a missing feature, or just a misuse of either framework.
urql version & exchanges:
@urql/core
: 2.3.1@urql/svelte
: 1.3.0Steps to reproduce
I managed to reproduce the issue in https://github.com/Nickersoft/urql-repro. Just be sure to run
yarn
first.yarn dev
yarn build && yarn preview
Expected behavior
I'd imagine URQL to run client-side in both cases, avoiding the above error which is often caused by calling
setContext()
on the server.Actual behavior
Dev server works, production build does not
The text was updated successfully, but these errors were encountered: