ChunkLoadError: Loading chunk 4512 failed. (missing: https://example.com/_next/static/chunks/4512-a1b2c3d4.js)
Next.js · updated 2026-11-04
Thrown in the browser by the webpack runtime when a lazily loaded chunk fails to load: "missing" means the request completed but the file wasn't there (a 404 after a deploy), "timeout" and "error" mean the request itself failed. It surfaces in the browser console and in client-side error tracking, not in server logs.
ChunkLoadError: Loading chunk 4512 failed.
(missing: https://example.com/_next/static/chunks/4512-a1b2c3d4.js)
at __webpack_require__.f.j (https://example.com/_next/static/chunks/webpack-8f2c.js:1:3912)
at https://example.com/_next/static/chunks/webpack-8f2c.js:1:1311Quick fix
If it follows deploys and says missing, the old HTML is asking for chunk files the new build replaced. Set a deploymentId per deployment so Next.js reloads the page when the deployment changes, keep the previous build's /_next/static files available for a while, and as a fallback reload once when a ChunkLoadError is caught. If it says timeout or error, look at the network: blocked requests, a CDN problem or flaky mobile connections.
- Look at the part in parentheses: missing (file gone, usually a deploy) vs timeout or error (network).
- Set deploymentId (or NEXT_DEPLOYMENT_ID) to a per-deploy value so mismatched clients do a full reload.
- Keep old /_next/static files for at least a few hours after a deploy (most CDNs and object storage can keep them).
- Don't cache HTML pages long at the CDN: cached HTML points at chunk files that no longer exist.
- Fallback: catch ChunkLoadError in an error boundary or window error handler and reload the page once.
// app/error.tsx (route error boundary): reload once on a stale chunk
'use client';
export default function ErrorBoundary({ error }: { error: Error & { digest?: string } }) {
if (typeof window !== 'undefined' && error.name === 'ChunkLoadError' && !sessionStorage.getItem('chunk-reload')) {
sessionStorage.setItem('chunk-reload', '1');
window.location.reload();
return null;
}
return <p>Something went wrong. Please reload the page.</p>;
}Why it happens
Deploy replaced the old chunks
A tab opened before the deploy navigates to a page whose code was split into a chunk with an old hashed name that the new server no longer has.
HTML cached longer than assets
A CDN keeps serving cached HTML from the old build while the old chunk files are gone.
Network or blocking
timeout or error instead of missing: slow mobile connections, corporate proxies, browser extensions or a CDN outage blocked the request.
Wrong asset prefix
assetPrefix or basePath set differently from where the files are served makes every lazy chunk 404, not just after deploys.
Other fixes
- CSS chunks fail the same way with "Loading CSS chunk … failed".
- Report these with the deployment ID attached so you can tell skew from real breakage in your error tracker.
Same error, other wording
- ChunkLoadError: Loading chunk 123 failed. (timeout: https://example.com/_next/static/chunks/123.js)
- Loading CSS chunk 456 failed.
- ChunkLoadError: Loading hot update chunk app/layout failed.
Let your coding agent catch the next one
This error happens in the browser, and Runheed doesn't capture browser errors yet: there is no browser SDK. What it does record is the server side of your app (route handlers, server rendering, API errors and background jobs) with the stack trace and the breadcrumbs before it, and serves those errors to Claude Code, Cursor or any MCP client.
Related errors
- Failed to find Server Action "7f3a9c2e". This request might be from an older or newer...
- Hydration failed because the server rendered HTML didn't match the client. As a result...
- Module not found: Can't resolve '@/components/OrderTable'
More in React and Next.js rendering
- An error occurred in the Server Components render. The specific message is omitted in...Next.js
- Dynamic server usage: Route /x couldn't be rendered statically because it used `headers`.Next.js
- ReferenceError: window is not definedNext.js
- Error: Event handlers cannot be passed to Client Component props.Next.js
- Only plain objects, and a few built-ins, can be passed to Client Components from Server...Next.js
- Route "/orders/[id]" used `params.id`. `params` should be awaited before using its...Next.js
- Error: NEXT_REDIRECTNext.js
- Error: NextRouter was not mounted.Next.js
- Invalid src prop (https://cdn.example.com/p/42.jpg) on `next/image`, hostname...Next.js
- TypeError: Failed to parse URL from /api/ordersNext.js
- Too many re-renders. React limits the number of renders to prevent an infinite loop.Next.js
- useSearchParams() should be wrapped in a suspense boundary at page "/search".Next.js
- You're importing a module that depends on `useState` into a React Server Component...Next.js
- Objects are not valid as a React child (found: object with keys {id, name, total}). If...Next.js
- Element type is invalid: expected a string (for built-in components) or a class/function...Next.js
References: Next.js docs: deploymentId (version skew), webpack source: the ChunkLoadError message