sveltejs / sveltejs/kit

bug: Failed to fetch dynamically imported module after internet reconnect

Open
#13,655 4 comments 2 reactions 0 assignees View on GitHub

Nobody has claimed this yet.

blocked by upstream router
Dominant language
JavaScript
Stars
20.8k
Forks
2.3k
Avg merge
1d 16h
Merged PRs (30d)
156

Description

Describe the bug

If the user encounters an error while loading a page, for example due to missing internet connection, the page keeps erroring even when the user has regained internet connection. This makes it so that the user has to refresh the page in order to access the page since its broken in their current application state.

This issue causes the application to always throw the TypeError: Failed to fetch dynamically imported module: error every time the user tries to navigate to the broken route. The only way we have managed to fix the issue is by refreshing the browser tab

Reproduction

Steps to reproduce:

  1. Load the application
  2. Turn off wifi
  3. Click the visit route 1 link such that it errors due to missing internet connection
  4. Navigate back to the root page and enable wifi again
  5. Wait until internet connection has been established and click the route 1 link again
  6. See that the page still errors

This behavior can be tested on this deployed application here which was deployed from this minimal reproduction. A gif showing how I'm able to trigger the error can be seen below

We have not been able to reproduce the bug without having it deployed since this reproduction relies on internet connection and remote requests.

Image

Minimal repro: https://github.com/AndersRobstad/svelte-network-error
Deployed application: https://svelte-network-error.vercel.app/

Logs
`GET` https://svelte-network-error.vercel.app/_app/immutable/nodes/3.C8tI2mkf.js net::ERR_INTERNET_DISCONNECTED
`TypeError`: Failed to fetch dynamically imported module: https://svelte-network-error.vercel.app/_app/immutable/nodes/3.C8tI2mkf.js
`GET` https://svelte-network-error.vercel.app/_app/version.json net::ERR_INTERNET_DISCONNECTED
`TypeError`: Failed to fetch dynamically imported module: https://svelte-network-error.vercel.app/_app/immutable/nodes/3.C8tI2mkf.js
`GET` https://svelte-network-error.vercel.app/_app/version.json net::ERR_INTERNET_DISCONNECTED
`TypeError`: Failed to fetch dynamically imported module: https://svelte-network-error.vercel.app/_app/immutable/nodes/3.C8tI2mkf.js
`TypeError`: Failed to fetch dynamically imported module: https://svelte-network-error.vercel.app/_app/immutable/nodes/3.C8tI2mkf.js
`TypeError`: Failed to fetch dynamically imported module: https://svelte-network-error.vercel.app/_app/immutable/nodes/3.C8tI2mkf.js
`TypeError`: Failed to fetch dynamically imported module: https://svelte-network-error.vercel.app/_app/immutable/nodes/3.C8tI2mkf.js
`TypeError`: Failed to fetch dynamically imported module: https://svelte-network-error.vercel.app/_app/immutable/nodes/3.C8tI2mkf.js
System Info
System:
    OS: macOS 15.3.2
    CPU: (10) arm64 Apple M2 Pro
    Memory: 99.38 MB / 16.00 GB
    Shell: 5.9 - /bin/zsh
  Binaries:
    Node: 22.14.0 - ~/.nvm/versions/node/v22.14.0/bin/node
    pnpm: 10.6.5 - ~/.nvm/versions/node/v22.14.0/bin/pnpm
  Browsers:
    Brave Browser: 133.1.75.178
    Chrome: 134.0.6998.166
    Edge: 134.0.3124.95
    Safari: 18.3.1
  npmPackages:
    @sveltejs/adapter-auto: ^4.0.0 => 4.0.0
    @sveltejs/kit: ^2.16.0 => 2.20.2
    @sveltejs/vite-plugin-svelte: ^5.0.0 => 5.0.3
    svelte: ^5.0.0 => 5.25.3
    vite: ^6.0.0 => 6.2.3
Severity

serious, but I can work around it

Additional Information

No response

Contributor guide

Open the contributing guide

First steps

  1. Read the whole issue, then the project's contributing guide.
  2. Comment on the issue to say you are picking it up — it saves two people doing the same work.
  3. Fork the repository and make your change on a branch.
  4. Open a pull request that references the issue number.

Research direction

Start with the linked minimal reproduction and deployed application, reproducing the failed dynamic import by disabling and then restoring the network. Trace the navigation and dynamic-import recovery behavior described in the issue; done means the route loads successfully after reconnecting without requiring a browser refresh.

Written by the indexing model from the issue text.

Assessment

Tech stack
javascript, vite
Domain
frontend, web-dev
Issue type
Bug
Difficulty
4/5
Estimated time
3-5 days
Activity status
Stale
Clarity
Mostly clear
Newbie friendliness
35/100

Get new issues in your inbox

A short digest of beginner-friendly GitHub issues.