fix(turbopack): allow dynamic import retry after chunk load failure#93518
Open
themhoeshateme wants to merge 1 commit into
Open
fix(turbopack): allow dynamic import retry after chunk load failure#93518themhoeshateme wants to merge 1 commit into
themhoeshateme wants to merge 1 commit into
Conversation
Author
|
Marking this ready for review so the maintainer-gated workflows can run. I verified I’d appreciate guidance if generated Turbopack runtime artifacts or snapshots should also be updated in this PR. |
e7be2e6 to
1fe1c45
Compare
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
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:
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
ChunkLoadErrorbehavior intact and does not swallow or replace the original error.Regression coverage was added in
test/production/chunk-load-failure/chunk-load-failure.test.tswith a new/retryfixture. The test aborts the first async chunk request, confirmsChunkLoadError, clicks the same load button again, allows the chunk request to continue, and verifies the lazy module renders.Verification
git diff --checkpassed.lint-stagedpassed.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.