Skip to content

Reload once when a deploy leaves a tab holding an old chunk - #175

Merged
Programcode merged 2 commits into
mainfrom
cursor/reload-stale-chunk-791b
Oct 22, 2026
Merged

Programcode merged 2 commits into
mainfrom
cursor/reload-stale-chunk-791b

Conversation

@Programcode

Copy link
Copy Markdown
Owner

After a deploy, an open tab can request a script the new build no longer has. The app then showed "Unable to load this page." The service worker could also store an HTML response as if it were that script, so the next load kept failing from cache.

The app now listens for Vite's preload error and reloads once per path. A second failure on the same path stays on the error screen, so a missing file cannot refresh the tab forever. The service worker skips caching when a script, style, or /assets/ response is HTML, and the cache version moved from v3 to v4 so an already poisoned cache is dropped on activate.

No layout change. The visible behavior is one automatic reload after a stale chunk, then the existing error screen if it still fails.

Verified locally (GitHub Actions is out of minutes, so this is not a CI pass):

  • npx vitest run src/test/lib/reload-stale-chunk.test.ts src/test/vercel-deployment-config.test.ts (20 passed)
  • npx eslint on the touched TypeScript files
  • npm run typecheck

Not run: npm run test:sw (the Playwright offline worker) and npm run verify.

Open in Web Open in Cursor 

cursoragent and others added 2 commits October 22, 2026 10:57
A missing script showed Unable to load this page, and the service worker
could store an HTML error as if it were that script. The tab now reloads
once per path, and HTML is no longer cached for scripts, styles, or assets.

Co-authored-by: Gáborjáni-Szabó Ádám <Programcode@users.noreply.github.com>
Co-authored-by: Gáborjáni-Szabó Ádám <Programcode@users.noreply.github.com>
@vercel

vercel Bot commented Oct 22, 2026 •

Copy link
Copy Markdown

The latest updates on your projects. Learn more about Vercel for GitHub.

Project Deployment Actions Updated
debate-navigator Ready Ready Preview Oct 22, 2026 11:16am UTC
debatelab-staging Ready Ready Preview Oct 22, 2026 11:16am UTC

@coderabbitai

coderabbitai Bot commented Oct 22, 2026 •

Copy link
Copy Markdown

Warning

Review limit reached

Enable usage-based reviews in Billing to review now. Otherwise, wait until the next included review is available.
You're only billed for reviews past your plan's rate limits ($0.25/file).

Next included review available in 48 minutes.

Check out review usage here.

View limit details

Limit details: You’ve used the included review currently available.

Learn how review limits work.

Review configuration:

⚙️ Run configuration
📥 Commits

Reviewing files that changed from the base of the PR and between 4f9e0a0 and a39cb45.

📒 Files selected for processing: 5
  • public/sw.js
  • src/lib/reload-stale-chunk.ts
  • src/main.tsx
  • src/test/lib/reload-stale-chunk.test.ts
  • src/test/vercel-deployment-config.test.ts
  • Autofix · Keep fixing CodeRabbit findings and required CI, and resolving merge conflicts

Note

🎁 Summarized by CodeRabbit Free

Your organization is on the Free plan. CodeRabbit will generate a high-level summary and a walkthrough for each pull request. For a comprehensive line-by-line review, please upgrade your subscription to CodeRabbit Essentials by visiting https://app.coderabbit.ai/settings/billing.

Comment @coderabbitai help to get the list of available commands.

Copilot AI left a comment

Copy link
Copy Markdown

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Copilot was unable to review this pull request because the user who requested the review has reached their quota limit.

@Programcode
Programcode merged commit 34fb585 into main Oct 22, 2026
7 of 14 checks passed

This branch was successfully deployed

2 active deployments
Preview – debate-navigator — a39cb45d Deployed Oct 22, 2026 by vercel[bot]
Preview – debatelab-staging — a39cb45d Deployed Oct 22, 2026 by vercel[bot]
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.

3 participants