question-mark
Stuck on an issue?

Lightrun Answers was designed to reduce the constant googling that comes with debugging 3rd party libraries. It collects links to all the places you might be looking at while hunting down a tough bug.

And, if you’re still stuck at the end, we’re happy to hop on a call to see how we can help out.

Circular dependencies throw error 500

See original GitHub issue

Describe the bug SvelteKit throws an error when using components with circular dependencies. Repository was created with commands shown on SK homepage and almost nothing was changed. I only included components from REPL.

Logs Console

Circular dependency: path/to/repo/src/routes/index.svelte -> /src/lib/App.svelte -> /src/lib/Structure.svelte -> /src/lib/C.svelte -> /src/lib/Structure.svelte

To Reproduce

I created repo with the problem here https://github.com/lukeeno/recursive-sveltekit

and also REPL with basically the same code, but in REPL it works https://svelte.dev/repl/c90b530e67c94b8995bf4bb5b7f70d3b?version=3.35.0

Expected behavior Not throwing error and recursively render components as shown in REPL

Stacktraces

Browser message
500
Cannot read property 'default' of null

TypeError: Cannot read property 'default' of null
    at path/to/repo/src/lib/C.svelte:7:22
    at Object.$$render (path/to/repo/node_modules/svelte/internal/index.js:1369:22)
    at eval (/src/lib/Structure.svelte:18:197)
    at Proxy.each (path/to/repo/node_modules/svelte/internal/index.js:1335:16)
    at path/to/repo/src/lib/Structure.svelte:15:7
    at Object.$$render (path/to/repo/node_modules/svelte/internal/index.js:1369:22)
    at eval (/src/lib/App.svelte:21:97)
    at Object.$$render (path/to/repo/node_modules/svelte/internal/index.js:1369:22)
    at eval (path/to/repo/src/routes/index.svelte:11:91)
    at Object.$$render (path/to/repo/node_modules/svelte/internal/index.js:1369:22)

Information about your SvelteKit Installation:

  • The output of npx envinfo --system --npmPackages svelte,@sveltejs/kit --binaries --browsers
  System:
    OS: Linux 5.9 Manjaro Linux
    CPU: (8) x64 Intel(R) Core(TM) i7-10510U CPU @ 1.80GHz
    Memory: 1.29 GB / 15.34 GB
    Container: Yes
    Shell: 5.8 - /bin/zsh
  Binaries:
    Node: 14.16.0 - /usr/bin/node
    npm: 7.6.3 - /usr/bin/npm
  Browsers:
    Brave Browser: unknown
    Firefox: 86.0.1
  npmPackages:
    @sveltejs/kit: next => 1.0.0-next.60 
    svelte: ^3.29.0 => 3.35.0
  • Your browser Brave Version 1.20.103 Chromium: 88.0.4324.152 (Official Build) unknown (64-bit)

  • Your adapter Node

Severity

Really severe if you need circular dependencies, but apart from that it’s okay

Additional context

Is there any workaround with async component loading?

Issue Analytics

  • State:closed
  • Created 2 years ago
  • Comments:7 (2 by maintainers)

github_iconTop GitHub Comments

2reactions
Buraburaitecommented, Aug 4, 2021
1reaction
Rich-Harriscommented, Mar 25, 2021

I guess this is a Vite issue. It’s definitely solvable — SvelteKit used to have an SSR runtime that handled this case, but we removed it because Vite implemented something very similar — though I can’t speak to how straightforward it would be to add it to Vite. Looks like there’s a couple of related issues already, e.g. https://github.com/vitejs/vite/issues/2258

Read more comments on GitHub >

github_iconTop Results From Across the Web

Circular dependency in ASP.NET Core
NET Entity Core Framework. I've written my api but when I tried to use it in swagger, it always returned a HTTP 500...
Read more >
Circular dependencies between services.
I thought angular's injector threw exception on circular dependency, but you are right ... The $xhr.error, for every HTTP 500, to wait 10...
Read more >
Circular includes in pipeline config no longer being detected ...
gitlab-ci.yml file via the Repository file editor a 500 error is generated upon committing the change. Steps to reproduce. Create a new project ......
Read more >
How to fix nasty circular dependency issues once and for ...
So, the Leaf class tries to extend from the undefined value, rather than a valid class. Which throws the runtime exception shown above....
Read more >
Solved: Strange Circular Dependency issue
It suggest that there is a circular dependency detected. This expression is placed in a customn column of 'EMEA - Standard_1'. The field...
Read more >

github_iconTop Related Medium Post

No results found

github_iconTop Related StackOverflow Question

No results found

github_iconTroubleshoot Live Code

Lightrun enables developers to add logs, metrics and snapshots to live code - no restarts or redeploys required.
Start Free

github_iconTop Related Reddit Thread

No results found

github_iconTop Related Hackernoon Post

No results found

github_iconTop Related Tweet

No results found

github_iconTop Related Dev.to Post

No results found

github_iconTop Related Hashnode Post

No results found