Dynamic imports sometimes fail after deployment, app stuck at `Loading...`
Nobody has claimed this yet.
- Dominant language
- JavaScript
- Stars
- 20.8k
- Forks
- 2.3k
- Avg merge
- 1d 16h
- Merged PRs (30d)
- 156
Description
Describe the bug
Description
I have a long-running SvelteKit app (maintained and upgraded regularly for 2+ years).
Recently, after adding async Svelte components and remote functions, the app works normally in most cases.
However, sometimes after deployment, the new version gets stuck at Loading... (I have SvelteKit boundary with a pending snippet in +layout.svelte).
- Refreshing does not resolve it.
- Issue appears browser-specific (seen on Samsung browser on mobile).
- Clearing cookies/cache fixes it.
- Different browsers load the site fine.
Logs from chrome://inspect (some parts are cleaned up)
GET /_app/immutable/chunks/DL90h7xO.js net::ERR_ABORTED 404 (Not Found)
TypeError: Failed to fetch dynamically imported module: /_app/immutable/nodes/0.FB441CHC.js
at handleError (app.js:2)
at J (runtime.js:2)
at fr (runtime.js:2)
at kr (runtime.js:2)
Uncaught (in promise) TypeError: Failed to fetch dynamically imported module: /_app/immutable/nodes/0.FB441CHC.js
Notes
- This seems to happen when the browser has cached an old version of assets.
- Clearing cache allows the app to load correctly.
- Possibly related to immutable asset caching, dynamic import resolution, or deployment cache invalidation.
Expected behavior
After deployment, the app should not fail to load due to missing dynamic import chunks.
Reproduction
The issue is difficult to reproduce and happens randomly.
Logs
System Info
System:
OS: macOS 26.0
CPU: (8) arm64 Apple M1
Memory: 151.78 MB / 8.00 GB
Shell: 5.9 - /bin/zsh
Binaries:
Node: 22.18.0 - ~/.nvm/versions/node/v22.18.0/bin/node
npm: 10.9.3 - ~/.nvm/versions/node/v22.18.0/bin/npm
pnpm: 10.3.0 - ~/.nvm/versions/node/v22.18.0/bin/pnpm
bun: 1.2.21 - ~/.bun/bin/bun
Browsers:
Chrome: 140.0.7339.133
Safari: 26.0
npmPackages:
@sveltejs/adapter-node: ^5.3.2 => 5.3.2
@sveltejs/kit: 2.38.1 => 2.38.1
@sveltejs/vite-plugin-svelte: ^5.1.1 => 5.1.1
svelte: ^5.38.10 => 5.38.10
vite: ^6.3.6 => 6.3.6
Severity
annoyance
Additional Information
No response
Contributor guide
First steps
- Read the whole issue, then the project's contributing guide.
- Comment on the issue to say you are picking it up — it saves two people doing the same work.
- Fork the repository and make your change on a branch.
- Open a pull request that references the issue number.
Research direction
Start with the pending snippet in +layout.svelte and the dynamic-import errors reported from app.js and runtime.js. Reproduce a deployment with cached immutable assets, paying attention to the missing chunks and Samsung Browser behavior. Done means a deployed app no longer remains stuck at Loading when an older cached version requests unavailable dynamic-import assets.
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
- Quiet
- Clarity
- Needs clarification
- Newbie friendliness
- 38/100