Errors and releases that break pages · mid
Stale tabs, hashed files and ChunkLoadError
Chunk file names contain a hash that changes each build. An old tab or old HTML asks for files the new deploy removed. Correct caching rules and keeping old files for some days prevent it.
Explain it out loud
Explain it out loud to an AI interviewer that follows up, and see where your answer is thin.
Practise by voiceThe notes
What you must know
- Mechanism: an old tab, or old HTML at the CDN, asks for chunks the new deploy deleted. The dynamic import gets a 404, so the navigation does nothing.
- Right now: put the previous build static files back online, and add a handler that does one full reload on a chunk-load failure, with a guard so it cannot loop.
- New visitors failing means stale HTML at the CDN still points to old chunk names, or a rolling deploy where servers run different builds.
- Caching rules: HTML is short-lived or revalidated (no-cache or a short s-maxage). Hashed assets are immutable for a year. Old assets are kept for days, never deleted at deploy time.
- Next.js: set deploymentId, the same on every instance of one deploy. Next adds ?dpl= to asset URLs and does a full reload when the server deployment id differs from the client one. Routing requests by deployment must come from the host or CDN.
- Rolling deploys: drain old servers first, or keep static assets on shared storage or a CDN so both versions stay available.
- Prevent: a deploy check that the previous release asset URLs still return 200, and an alert on the ChunkLoadError rate after each release.
The red pen
Common traps: mistake → fix
Mistake: Hashed file names mean old tabs never break
Fix: old tabs ask for old names; keep old files for some days.
Mistake: Deleting the old build after deploy saves space safely
Fix: it breaks every open tab.
Mistake: Long cache on HTML is fine
Fix: HTML must be short-lived or revalidated.
Easy to hard
Questions interviewers ask, easy to hard
- ChunkLoadError spikes after every deploy. Why?
- How do you handle a chunk load failure in code without a reload loop?
- What cache rules do you set for HTML and for hashed assets?
- How do you deploy safely with several servers running different versions?
Explain it out loud
Explain it out loud to an AI interviewer that follows up, and see where your answer is thin.
Practise by voiceYour first interview is free
Sign up and start with a 15-minute interview with the full report, and an English conversation. No card needed.