Repository navigation
fix(web): a chunk that fails after boot no longer reloads the page in a loop #29306
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Merged
juliusmarminge
merged 6 commits into
pingdotgg:main
from
grodriguez-fr:fix/chunk-reload-guard-loop
Nov 12, 2026
+48
−20
Merged
Changes from all commits
Commits
Show all changes
6 commits
Select commit
Hold shift + click to select a range
0e31f94
fix(web): a chunk that fails after boot no longer reloads the page in…
grodriguez-fr 0517b1d
test(web): cover a lazy chunk that fails after every boot
grodriguez-fr 201fe25
fix(web): key the chunk reload guard by build instead of a time window
grodriguez-fr 8cd53a5
test(web): keep only the chunk reload tests that fail on main
grodriguez-fr 88e4f60
Merge remote-tracking branch 'origin/main' into fix/chunk-reload-guar…
juliusmarminge eb54b1e
test(web): stub the i18n runtime in the chunk reload boot test
juliusmarminge File filter
Filter by extension
Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
There are no files selected for viewing
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
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
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
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -0,0 +1,37 @@ | ||
| import { expect, it, vi } from "vite-plus/test"; | ||
|
|
||
| vi.mock("./appInit", () => ({ startAppServices: () => ({ load: async () => {} }) })); | ||
| vi.mock("./AppRoot", () => ({ AppRoot: () => null })); | ||
| vi.mock("./i18n/runtime", () => ({ whenLocaleReady: async () => {} })); | ||
| vi.mock("react-dom/client", () => ({ default: { createRoot: () => ({ render: () => {} }) } })); | ||
|
|
||
| // Boots main in a fresh page that shares the tab's sessionStorage, as a reload does. | ||
| async function bootThenFailLazyChunk(sessionStorage: Map<string, string>) { | ||
| vi.resetModules(); | ||
| const reload = vi.fn().mockName("location.reload"); | ||
| const page = Object.assign(new EventTarget(), { | ||
| sessionStorage: { | ||
| getItem: (key: string) => sessionStorage.get(key) ?? null, | ||
| setItem: (key: string, value: string) => sessionStorage.set(key, value), | ||
| removeItem: (key: string) => sessionStorage.delete(key), | ||
| }, | ||
| location: { reload }, | ||
| }); | ||
| vi.stubGlobal("window", page); | ||
| vi.stubGlobal("document", { getElementById: () => ({}) }); | ||
| try { | ||
| const { startup } = await import("./main"); | ||
| await startup; | ||
| page.dispatchEvent(new Event("vite:preloadError", { cancelable: true })); | ||
| return reload; | ||
| } finally { | ||
| vi.unstubAllGlobals(); | ||
| } | ||
| } | ||
|
|
||
| it("reloads only once when a lazy chunk fails after every boot", async () => { | ||
| const sessionStorage = new Map<string, string>(); | ||
|
|
||
| expect(await bootThenFailLazyChunk(sessionStorage)).toHaveBeenCalledTimes(1); | ||
| expect(await bootThenFailLazyChunk(sessionStorage)).not.toHaveBeenCalled(); | ||
| }); |
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
Oops, something went wrong.
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.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Handle boot-time chunk failures after the reload guard is consumed.
After one reload for an
APP_VERSION,reloadOnceForChunkLoadError()returnsfalse, soreloadScheduledstaysfalse. If themanagedAuthShellModuleimport rejects with a chunk-load error, the.catchinapps/web/src/main.tsxrethrows. TheReactDOM.createRoot(...).render(...)call is never reached.AppRoot, its route error boundary, and its reload option do not mount. The page shows no recovery UI, and the failure surfaces only as an unhandled rejection ofstartup.The PR describes later failures on the same version as showing an error with a reload option. That holds for route chunks that fail after boot. It does not hold for these startup dependencies, because their failures occur before the app tree mounts.
A correct fix needs a design decision for the startup fallback. The inspected code does not establish that decision, so this comment does not propose a patch.