fix: let error boundaries handle chunk loading failures - #1440
Open
MikitasK wants to merge 4 commits into
Open
Conversation
🦋 Changeset detectedLatest commit: 5b86570 The changes in this PR will be included in the next version bump. This PR includes changesets to release 6 packages
Not sure what this means? Click here to learn what changesets are. Click here if you're a maintainer who wants to add another changeset to this PR |
|
@MikitasK is attempting to deploy a commit to the Callstack Team on Vercel. A member of the Team first needs to authorize it. |
dannyhw
reviewed
Aug 13, 2026
| Object.getOwnPropertyNames(originalWebpackRequire).forEach((key) => { | ||
| // @ts-ignore | ||
| guardedWebpackRequire[key] = originalWebpackRequire[key]; | ||
| var descriptor = Object.getOwnPropertyDescriptor( |
Collaborator
There was a problem hiding this comment.
how do these changes to copy the properties impact the fix? or does it solve some other issue?
Contributor
Author
There was a problem hiding this comment.
good catch, thanks 👍 basically, these changes don't directly impact 'chunk load error' fix.
so I just reverted it to keep this PR focused on chunk loading error & not brake any existing logic
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.
Summary
Closes #1428
MF v.2 can surface failed remote chunk load through synthetic module factory. Resulting
ChunkLoadErrorpasses through Re.Pack's guarded__webpack_require__, where it's reported as fatal. This bypasses dynamic-import rejection path preventingReact.lazyError Boundaries from handling failure & causing Release app to terminatechunk_loading_error_on_prod.mp4
PR change keeps Metro-compatible guarded require but allows
ChunkLoadErrorto propagate to dynamic-import promise. promise can then reject normally & be handled by nearest Error BoundaryErrorUtils.reportFatalErrorrequire()failures remain catchablefixed_chunk_loading_error_on_prod.mp4
Test plan
In repo root:
pnpm --filter @callstack/repack typecheckpnpm --filter @callstack/repack run build:jspnpm --filter @callstack/repack run build:tspnpm --filter integration-test test -- RepackTargetPlugin.test.tsIn
apps/tester-federation-v2:build/mini-appon port 8082:adb reverse tcp:8082 tcp:8082Galleryin appExpected result:
ChunkLoadErrorGalleryrenders "Failed to load Mini App" fallback