Blank page or dead links right after a deploy? Fix chunk load errors

You publish an update and everything looks fine. Then someone who already had your site open clicks a link, and nothing happens. Or the page goes blank. In the console there's an error like Failed to fetch dynamically imported module, Importing a module script failed or ChunkLoadError: Loading chunk 12 failed. A refresh fixes it, so you can't reproduce it, but some visitors hit it after every deploy.

The symptom

  • Right after a deploy, some visitors see a blank page or a link that does nothing.
  • The console shows a failed module or chunk load, or Expected a JavaScript module script but the server responded with a MIME type of "text/html".
  • Reloading the page fixes it. A fresh visitor never sees it.

Why it happens

Most sites made with Lovable, Bolt, v0, Replit or Cursor are built with a bundler such as Vite or Next.js. The bundler splits your code into many small files, called chunks, and gives each a name that includes a hash of its contents, like /assets/Pricing-a1b2c3.js. Pages load their chunk only when someone navigates to them.

When you deploy a change, the hashes change and the host replaces the old files with new ones. A visitor whose tab was opened before the deploy is still running the old code, which asks for Pricing-a1b2c3.js. That file no longer exists.

Two things make it worse:

  • The SPA rewrite. Single-page sites usually send any unknown path to index.html. So the missing JavaScript file comes back as an HTML page with a 200 status, and the browser refuses to run it.
  • Caching. If index.html itself is cached by the browser, a CDN or a service worker, even a reload can load the old page, which points at chunks that are gone.

Step-by-step diagnosis

  1. Reproduce it. Open your live site and leave the tab open. Publish any small change. Back in the old tab, without reloading, click through to a page you haven't visited yet.
  2. Read the console. Look for one of the errors above and note the file name that failed.
  3. Request that file directly. Run curl -I https://yoursite.com/assets/the-file.js. A 404, or a 200 with content-type: text/html, confirms the old chunk is gone.
  4. Check how index.html is cached. Run curl -I https://yoursite.com/ and look at cache-control. A long max-age on the HTML means visitors can keep an old page for a long time.
  5. Check for a service worker. In browser DevTools, open Application, then Service Workers. A PWA plugin may be serving an old copy of your site.

Fixes per builder and host

Vite apps (most Lovable and Bolt projects)

Vite fires a vite:preloadError event on window when a dynamic import fails. Listen for it and reload the page once, so the visitor gets the new version. Guard it, for example with a flag in sessionStorage, so a real outage can't cause a reload loop.

Lovable

Ask Lovable: "When a lazy-loaded page fails to load after a new deploy, reload the page once using the vite:preloadError event, with a guard against reload loops. Make sure index.html isn't cached long-term." Then republish and test as above.

Bolt and Netlify

Add the same reload handler. In a Netlify _headers file, give /index.html cache-control: no-cache and give /assets/* a long cache with immutable, since hashed files never change.

v0, Next.js and Vercel

Next.js reports these as ChunkLoadError. Vercel has a feature called Skew Protection that keeps serving a visitor's original deployment files; check whether your plan includes it. Otherwise, catch the error in an error boundary and offer a reload.

Replit

Each deployment replaces the built files. Add the reload handler and set no-cache on the HTML response from your server.

Cursor

Ask Cursor to "find how lazy routes are loaded, add a one-time reload on chunk load failure, and set no-cache on index.html in our host config".

Service workers

If you use a PWA plugin, make sure new versions activate and the page reloads, or remove the service worker if you don't need offline support.

How to verify

  • Repeat the open-tab test: leave a tab open, deploy, then navigate. The page should reload once and work.
  • Check curl -I shows no-cache (or a short max-age) on the HTML.
  • Watch the console on the live site after your next few deploys.

Prevention

  • Keep the reload-on-chunk-error handler in place permanently.
  • Cache hashed assets for a long time and the HTML for no time.
  • Deploy less often during your busiest hours if many visitors keep tabs open.
  • After each deploy, test with a tab that was open before it, not only a fresh one.
A fresh visit tests your new deploy. An old tab tests the switch between deploys, and that's where this bug lives.

FlowCanary's free check loads your live site in a real browser and reports console errors, blank pages and broken links, with a fix prompt for your builder.

Run the free 30-second check

Run the free 30-second check

← All posts

FlowCanary on SaaSHub