kit icon indicating copy to clipboard operation
kit copied to clipboard

Everything freezes on a weird combination of circular imports

Open rChaoz opened this issue 1 year ago • 0 comments

Describe the bug

Sorry for the poor title, but I don't have anything better. I've come this very weird bug during development where importing a simple plain object from a file causes SvelteKit to freeze entirely (browser loads the webpage forever, need to Ctrl+C the terminal and vite dev again). After hours of removing code until I remained with the bare minimum, this is the combination that causes it:

  • +page.svelte - only has a script with context module - declares a function and imports an object from Settings. Also imports getToastStore() from @skeletonlabs/skeleton
  • +Settings.svelte - only has a script with context module - declares an object and imports the function from +page. This has to be a svelte file and not a ts/js file.
  • +layout.svelte - only has a script with context module - imports the object from Settings

Note that this means the root layout doesn't even have a <slot/> - nothing is ever rendered. Removing any of the imports (even though they are never used) fixes the freeze (although restarting vite dev is required to see that).

Another note: there is nothing "wrong" with getToastStore() or the skeleton UI library - I've been using it successfully until now. The issue only arises when it is imported alongside the rest of the circular imports.

Reproduction

Note: I put some content (besides the script tag) in the layout to prove that it freezes (as that should be displayed). Everything else is as described above.

https://www.sveltelab.dev/hc1b5q7l40hm1f8

Logs

There are none.

System Info

System:
    OS: Windows 10 10.0.19045
    CPU: (20) x64 12th Gen Intel(R) Core(TM) i7-12700KF
    Memory: 11.33 GB / 31.86 GB
  Binaries:
    Node: 20.8.0 - C:\Program Files\nodejs\node.EXE
    Yarn: 1.22.19 - C:\Program Files\nodejs\yarn.CMD
    npm: 10.2.1 - C:\Program Files\nodejs\npm.CMD
  Browsers: // my note: I use Firefox and Chrome, why do these show up?
    Edge: Spartan (44.19041.1266.0)
    Internet Explorer: 11.0.19041.1566
  npmPackages:
    @sveltejs/adapter-node: ^1.3.1 => 1.3.1
    @sveltejs/kit: ^1.20.4 => 1.27.1
    svelte: ^4.0.5 => 4.2.2
    vite: ^4.4.2 => 4.5.0

Severity

serious, but I can work around it

Additional Information

No response

rChaoz avatar Feb 02 '24 13:02 rChaoz