Skip to content

fix(portal): self-recover stale tabs on any chunk load failure, offer reload on the 500 page - #11

Merged
balebbae merged 1 commit into
mainfrom
devin/1790539139-stale-chunk-reload
Sep 27, 2026
Merged

balebbae merged 1 commit into
mainfrom
devin/1790539139-stale-chunk-reload

Conversation

@devin-ai-integration

Copy link
Copy Markdown

Summary

Stale tabs/PWAs that lazy-load a content-hashed chunk deleted by a deploy could get stuck on the 500 ErrorPage: vite:preloadError only fires for imports that go through Vite's preload helper, and the existing buttons (navigate(-1) / navigate("/")) never fetch a fresh shell. Code-only; no infra changes.

stale-chunk-reload.ts:

  • isChunkLoadError(message) matches /failed to fetch dynamically imported module/i, /error loading dynamically imported module/i, /importing a module script failed/i, /chunkloaderror/i.
  • reloadOnce() factors out the RELOAD_STAMP_KEY / RELOAD_COOLDOWN_MS (10s, sessionStorage) guard + window.location.reload().
  • installStaleChunkReload() now wires three triggers through reloadOnce(): vite:preloadError (unchanged, preventDefault first), plus unhandledrejection and error listeners that fire only when isChunkLoadError matches the reason / error message. Shared cooldown prevents reload loops if the fresh build also fails.

ErrorPage.tsx: when the 500 detail matches isChunkLoadError, render a primary "A new version is available — reload" button calling window.location.reload() above the existing back/home buttons.

Verified: npm run lint, npm run format:check, npm run build in client/portal.

Link to Devin session: https://app.devin.ai/sessions/1348deb2b5ac4efb99688d4995a51f47
Open in Devin Desktop: https://app.devin.ai/desktop/session/1348deb2b5ac4efb99688d4995a51f47?variant=devin
Requested by: @balebbae

@devin-ai-integration

Copy link
Copy Markdown
Author

I'll fix CI failures and address comments from users with write access. I'll skip comments containing "(aside)".

  • Disable automatic comment, CI, and merge conflict monitoring

@balebbae
balebbae merged commit 3201851 into main Sep 27, 2026
3 checks passed
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

1 participant