{"id":"ec8205fd184361ff","repo":"webpack/webpack","slug":"loading-update-chunk-failed-for-unknown-reason","errorCode":null,"errorMessage":"Loading update chunk failed for unknown reason","messagePattern":"Loading update chunk failed for unknown reason","errorType":"exception","errorClass":"Error","httpStatus":null,"severity":"error","filePath":"lib/webworker/ImportScriptsChunkLoadingRuntimeModule.js","lineNumber":208,"sourceCode":"\t\t\t\t\t\t\t\tTemplate.indent([\n\t\t\t\t\t\t\t\t\t`if(${RuntimeGlobals.hasOwnProperty}(moreModules, moduleId)) {`,\n\t\t\t\t\t\t\t\t\tTemplate.indent([\n\t\t\t\t\t\t\t\t\t\t\"currentUpdate[moduleId] = moreModules[moduleId];\",\n\t\t\t\t\t\t\t\t\t\t`${runtimeTemplate.optionalChaining(\"updatedModulesList\", \"push(moduleId)\")};`\n\t\t\t\t\t\t\t\t\t]),\n\t\t\t\t\t\t\t\t\t\"}\"\n\t\t\t\t\t\t\t\t]),\n\t\t\t\t\t\t\t\t\"}\",\n\t\t\t\t\t\t\t\t\"if(runtime) currentUpdateRuntime.push(runtime);\",\n\t\t\t\t\t\t\t\t\"success = true;\"\n\t\t\t\t\t\t\t])};`,\n\t\t\t\t\t\t\t\"// start update chunk loading\",\n\t\t\t\t\t\t\t`importScripts(${\n\t\t\t\t\t\t\t\twithCreateScriptUrl\n\t\t\t\t\t\t\t\t\t? `${RuntimeGlobals.createScriptUrl}(${RuntimeGlobals.publicPath} + ${RuntimeGlobals.getChunkUpdateScriptFilename}(chunkId))`\n\t\t\t\t\t\t\t\t\t: `${RuntimeGlobals.publicPath} + ${RuntimeGlobals.getChunkUpdateScriptFilename}(chunkId)`\n\t\t\t\t\t\t\t});`,\n\t\t\t\t\t\t\t'if(!success) throw new Error(\"Loading update chunk failed for unknown reason\");'\n\t\t\t\t\t\t]),\n\t\t\t\t\t\t\"}\",\n\t\t\t\t\t\t\"\",\n\t\t\t\t\t\tgenerateJavascriptHMR(\"importScripts\")\n\t\t\t\t\t])\n\t\t\t\t: \"// no HMR\",\n\t\t\t\"\",\n\t\t\twithHmrManifest\n\t\t\t\t? Template.asString([\n\t\t\t\t\t\t`${\n\t\t\t\t\t\t\tRuntimeGlobals.hmrDownloadManifest\n\t\t\t\t\t\t} = ${runtimeTemplate.basicFunction(\"\", [\n\t\t\t\t\t\t\t'if (typeof fetch === \"undefined\") throw new Error(\"No browser support: need fetch API\");',\n\t\t\t\t\t\t\t`return fetch(${RuntimeGlobals.publicPath} + ${\n\t\t\t\t\t\t\t\tRuntimeGlobals.getUpdateManifestFilename\n\t\t\t\t\t\t\t}()).then(${runtimeTemplate.basicFunction(\"response\", [\n\t\t\t\t\t\t\t\t\"if(response.status === 404) return; // no update available\",\n\t\t\t\t\t\t\t\t'if(!response.ok) throw new Error(\"Failed to fetch update manifest \" + response.statusText);',","sourceCodeStart":190,"sourceCodeEnd":226,"githubUrl":"https://github.com/webpack/webpack/blob/318421ea8ac81371f5171236a6efb63675576528/lib/webworker/ImportScriptsChunkLoadingRuntimeModule.js#L190-L226","documentation":"In the webworker (importScripts) chunk loader, HMR loads an update chunk by calling importScripts(...) and expects the loaded script to invoke the registered global hot-update callback, which sets success = true. If the script returns without triggering that callback, success stays false and this error throws: the chunk was fetched but never registered its modules. This is a runtime error in the generated bundle, not at build time.","triggerScenarios":"The hot-update chunk file is empty or 404'd silently (importScripts swallows load errors); cross-origin without CORS so the script executes as a no-op; a syntax error in the chunk aborts before the callback runs; a filename/publicPath mismatch makes importScripts load the wrong or stale file.","commonSituations":"Worker script served cross-origin (CDN) without CORS headers; a stale/corrupt hot-update chunk left on disk; publicPath pointing somewhere the worker cannot read; dev server restarted mid-update leaving a half-written chunk.","solutions":["Verify the hot-update chunk file exists and is non-empty at the URL the worker is importing from.","Ensure publicPath and the worker's origin allow the script to be imported (same-origin, or proper CORS headers for importScripts).","Clear the dev-server output directory and restart to regenerate clean chunks.","Check the dev-server logs for a compile error on the update chunk that prevented the callback from being emitted."],"exampleFix":null,"handlingStrategy":"try-catch","validationCode":null,"typeGuard":null,"tryCatchPattern":"// In the worker, guard HMR apply so a chunk that failed to register does not\n// crash the worker — surface the error and skip this update cycle.\nif (self.module && self.module.hot) {\n  self.module.hot.dispose((data) => { /* save state */ });\n  self.module.hot.accept(() => {\n    try { /* re-import / re-init worker logic */ }\n    catch (e) { console.error('HMR update failed, keeping previous code:', e); }\n  });\n}","preventionTips":["Serve worker scripts same-origin, or send proper CORS headers — importScripts silently no-ops on cross-origin scripts without CORS, which is the usual cause of success staying false.","Keep output.publicPath on the dev server origin so the worker reads a fresh hot-update chunk each time.","Clear stale hot-update chunks from the output dir between dev-server restarts to avoid importing a half-written file."],"tags":["hmr","runtime","webworker","importscripts","network"],"analyzedSha":"318421ea8ac81371f5171236a6efb63675576528","analyzedAt":"2026-08-03T19:39:56.731Z","schemaVersion":2}