A deploy finishes, the dashboards look green, and then the error tracker fills with "Failed to fetch dynamically imported module" or "ChunkLoadError". Nobody on the team can reproduce it. A fresh page load works perfectly, which is exactly why the problem survives so many releases.
The users hitting it opened your application before the deploy. Their tab is still running the old JavaScript, and that code is now asking the server for files that no longer exist. The fix is mostly a matter of treating a release as something that overlaps with the previous one, because for your users it always does.

Photo by Brett Sayles on Pexels
Why a successful deploy breaks open tabs
Modern bundlers split an application into many files. The entry script loads first, and the rest arrive on demand when a user visits a route or opens a feature. Each file name usually includes a hash of its contents, so settings.4f2a.js becomes settings.9c1d.js the moment anything inside it changes. Tools such as webpack and Vite do this by default or with very little configuration.
The old entry script has the old file names baked into it. If your deploy replaces the whole output directory, those names stop resolving. The user clicks "Settings", the browser requests a file that was deleted four minutes ago, and the dynamic import rejects.
The same shape of failure shows up elsewhere. An old client may call an API field that was renamed, or send a payload the new server no longer accepts. Engineers call this version skew: two halves of one system running different releases at the same time. Missing chunks are simply the loudest version of it.
How often it happens depends on how long people keep tabs open. An internal dashboard that staff leave running all week will see it after almost every release. A marketing page with short visits may see it rarely, and mostly on slow connections.
Confirm what is actually failing
Before changing anything, find out which failure you have. Browsers word it differently: Chrome reports a failure to fetch a dynamically imported module, Firefox reports an error loading one, and Safari says importing a module script failed. Webpack builds throw an error named ChunkLoadError. Group all of these in your error tracker so they count as one problem.
Then look at the response for the missing file. A clean 404 is the honest case. A far more confusing one happens when a single page application is configured to return index.html for every unknown path. The request for a deleted script gets a 200 response containing HTML, and the console complains about the MIME type instead of a missing file.
That fallback rule should exclude your asset directory. A request under /assets/ for something that does not exist needs to return a real 404, with headers that stop any cache from holding on to it. Otherwise a CDN can store the wrong response and serve it to people who would have received the right file.
Record the build identifier with every error report. Once you can see that nearly all failures come from clients one or two releases behind, the cause stops being a mystery. Tools such as Sentry let you tag events with a release value for exactly this kind of comparison.
Keep the old files available
The most effective fix is also the least clever: stop deleting yesterday's assets. Publish new hashed files alongside the old ones, and remove old ones later on a schedule. Because every name is unique to its contents, two releases can share a directory without overwriting each other.

Photo by rescriptt rescriptt on Pexels
How long to keep them is a product decision. Two weeks covers most browser tabs left open over a weekend or a holiday. Storage for static scripts is cheap compared with the cost of a broken checkout. A reasonable rule is to keep every file referenced by any release from the past several weeks, and never fewer than the last few releases.
Order matters too. Upload the new assets first and confirm they are reachable. Switch the HTML only after that. If the HTML goes live before its scripts, even brand new visitors can hit missing files during the window.
Container deployments need extra care. If assets are baked into the application image, an old instance and a new instance each hold only their own files. During a rolling update, a page served by the new instance may request a chunk from the old one. Push static assets to object storage or a shared CDN origin during the build so any request can be answered regardless of which instance is alive.
Set cache headers that match each file type
Hashed assets and HTML need opposite caching rules. A hashed file can never change, so it can be cached for a year and marked immutable. The HTML document is the pointer to those files, so the browser should revalidate it before using a stored copy.
In practice that means Cache-Control: public, max-age=31536000, immutable for hashed scripts and styles, and Cache-Control: no-cache for HTML. Despite the name, no-cache allows storage but requires a check with the server first. The HTTP caching specification defines these directives, and MDN explains them in plainer language.
Check what actually reaches the browser, not just what your configuration file says. A CDN, a reverse proxy, or a hosting platform default can override headers. Request the HTML and one script from production and read the response headers directly.
Service workers deserve a separate look. A worker that serves cached HTML can keep a user on an old release long after your headers say otherwise. Decide explicitly how updates activate, and make sure the worker does not delete cached files that an open tab still depends on.
Recover gracefully when a chunk is missing
Retention windows end, and some tabs will outlive them. The client needs a plan for that. For a navigation, the simplest recovery is a full page load of the destination URL. The user asked to go somewhere, a real navigation fetches fresh HTML, and they arrive without noticing anything unusual.
Vite emits a vite:preloadError event on the window when a dynamically imported file fails to load, which gives you one place to handle it. In other setups, wrap your lazy route loader so a rejected import is caught, classified, and handled in a single function.
Guard against reload loops. Before reloading, store a marker in session storage with the build identifier and the time. If the same failure appears again right after a reload, stop and show a message with a manual retry. A broken release or a blocked network should never turn into a page that refreshes forever.
Retrying the same import in place is unreliable, because some browsers remember a failed module request for the life of the document. A single retry for a flaky connection is harmless, but do not depend on it.
"Treat the previous release as a supported client for a couple of weeks. Teams that plan for that overlap stop seeing mystery errors after deploys, and they ship more often because releasing no longer interrupts anyone." - Dennis Traina, founder of 137Foundry
Tell users when a new version is ready
Waiting for a failure is the fallback. A better experience is noticing the new release early. Publish a tiny version.json file with each build, and have the client fetch it when the tab becomes visible again or on a modest interval. Compare it with the identifier compiled into the running bundle.

Photo by AMORIE SAM on Pexels
When they differ, you have options. The gentlest is to upgrade on the next route change by doing a full navigation instead of a client-side one. The user never sees a prompt, and most tabs move forward within a few clicks.
A visible notice makes sense for long-lived screens where people rarely navigate. Keep it small and let them choose the moment. Never reload while a form has unsaved input, an upload is running, or a payment is in progress. If you must force an update for a security fix, save drafts first and say why.
Frameworks and hosts increasingly offer built-in skew protection. Next.js, for example, supports a deployment identifier that lets the client detect a mismatch and fall back to a hard navigation. Read the documentation for your own stack before writing this yourself.
Apply the same thinking to your API
Keeping old assets alive means old code keeps running, so the server has to tolerate it. Make API changes additive within the retention window. Add the new field, keep accepting the old one, and remove it only after the old clients have aged out. Database changes follow the same expand-then-contract order.
Send the client build identifier as a request header. It costs very little and tells you how many requests still come from older releases, which turns "can we delete this yet" into a question with a measurable answer.
When a client is too old to be served safely, respond with a specific status and error code that the front end understands, and have it prompt for a refresh. A generic server error sends the user to support with nothing useful to report.
Test the overlap before users do
This failure is easy to reproduce once you know the recipe. Open the application in a staging environment and leave the tab alone. Deploy a change that alters at least one lazily loaded route. Return to the old tab and visit that route.
Then repeat the exercise with old assets deliberately removed, to confirm the recovery path reloads once and stops. Run it a third time in the middle of a rolling update if you deploy that way. A browser automation tool can hold one page open across a deploy step, which makes this a repeatable pipeline check instead of a manual ritual.
Track the error count per release afterwards. A sudden rise usually points at a pipeline change that started cleaning the output directory again, or a new proxy rule rewriting asset requests to HTML.
Where to start
If you only do one thing this week, stop deleting old assets on deploy. Add correct cache headers next, then the guarded reload, and finally the version check. Each step helps on its own, and together they make releases quiet for the people using the product.
If your releases still interrupt users and the cause is spread across hosting, build tooling, and front end code, 137Foundry's web development service can trace the full path from build output to browser. You can read more about the team at 137Foundry.