Skip to content

fix(turbopack): allow dynamic import retry after chunk load failure#93518

Open
themhoeshateme wants to merge 1 commit into
vercel:canaryfrom
themhoeshateme:fix-turbopack-dynamic-import-retry-93489
Open

fix(turbopack): allow dynamic import retry after chunk load failure#93518
themhoeshateme wants to merge 1 commit into
vercel:canaryfrom
themhoeshateme:fix-turbopack-dynamic-import-retry-93489

Conversation

@themhoeshateme
Copy link
Copy Markdown

What?

Fixes #93489.

This updates the Turbopack browser runtime so failed dynamic chunk-load attempts do not leave rejected load state cached in a way that prevents later dynamic import() attempts from retrying.

Successful chunk loads continue to use the existing caching behavior. Failed loads rethrow the original error, but clear the failed cached state so a later user-triggered import can attempt to load the chunk again after connectivity is restored.

This intentionally does not add:

  • configurable retry
  • exponential backoff
  • runtime hooks
  • cache-busting URLs
  • webpack behavior changes

Why?

A transient chunk-load failure, such as a temporary offline/network failure, could leave rejected Promise state in Turbopack runtime caches. Later attempts to dynamically import the same chunk could reuse the failed state instead of issuing a fresh load attempt.

This meant the app could remain stuck until a full reload cleared runtime state.

How?

The runtime now evicts failed cached chunk-load entries on rejection while preserving successful and in-flight caching behavior.

The fix keeps the existing ChunkLoadError behavior intact and does not swallow or replace the original error.

Regression coverage was added in test/production/chunk-load-failure/chunk-load-failure.test.ts with a new /retry fixture. The test aborts the first async chunk request, confirms ChunkLoadError, clicks the same load button again, allows the chunk request to continue, and verifies the lazy module renders.

Verification

  • git diff --check passed.
  • Commit pre-hook / lint-staged passed.

I attempted the targeted Turbopack browser regression locally, but this checkout appears to require rebuilt Turbopack/native runtime artifacts for the browser test to exercise the edited TypeScript runtime source.

@github-actions github-actions Bot added tests Turbopack Related to Turbopack with Next.js. labels May 5, 2026
@themhoeshateme themhoeshateme marked this pull request as ready for review May 6, 2026 00:19
@themhoeshateme
Copy link
Copy Markdown
Author

Marking this ready for review so the maintainer-gated workflows can run.

I verified git diff --check and the commit pre-hook/lint-staged locally. The PR keeps the fix limited to evicting failed Turbopack chunk-load cache state on rejection, while preserving successful/in-flight caching and existing ChunkLoadError behavior.

I’d appreciate guidance if generated Turbopack runtime artifacts or snapshots should also be updated in this PR.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

tests Turbopack Related to Turbopack with Next.js.

Projects

None yet

Development

Successfully merging this pull request may close these issues.

Turbopack: dynamic import() failures stay failed no recovery path without a full page reload

1 participant