Menu

ChunkLoadError After a Next.js Deploy: Your CDN Cached the HTML
πŸ“°

ChunkLoadError After a Next.js Deploy: Your CDN Cached the HTML

DEV CommunityΒ·Kausar RazaΒ·11 days ago
#S3W2KabP
#dev#cache#build#deploy#purge
Reading 0:00
15s threshold

You deploy. The site comes back with no styling, or half the interactive bits are dead, and the console says:

ChunkLoadError: Loading chunk 478 failed. (missing: https://example.com/_next/static/chunks/3ivcc6t1s04dh.js)

Enter fullscreen mode

Exit fullscreen mode

You check the server. The file is not there β€” but a file with a different name is, and it contains exactly the code that is missing. Rebuild, redeploy, same thing. Open the site in a private window and it is perfect.

Almost everything written about this error blames the service worker, or webpack's output.publicPath , or tells you to catch the import and retry. On a Next.js site behind a CDN the cause is usually none of those.

Why the chunk name changes every build

Next.js fingerprints its JavaScript. A real filename from this site:

/_next/static/chunks/3ivcc6t1s04dh.js

Enter fullscreen mode

Exit fullscreen mode

That name is derived from the file's contents.…

Continue reading β€” create a free account

Join HashtagPLUS to read full articles, follow hashtags, vote, and join the conversation.