webpack/webpack · error · Error

Loading update chunk failed for unknown reason

Error message

Loading update chunk failed for unknown reason

What it means

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.

Source

Thrown at lib/webworker/ImportScriptsChunkLoadingRuntimeModule.js:208

								Template.indent([
									`if(${RuntimeGlobals.hasOwnProperty}(moreModules, moduleId)) {`,
									Template.indent([
										"currentUpdate[moduleId] = moreModules[moduleId];",
										`${runtimeTemplate.optionalChaining("updatedModulesList", "push(moduleId)")};`
									]),
									"}"
								]),
								"}",
								"if(runtime) currentUpdateRuntime.push(runtime);",
								"success = true;"
							])};`,
							"// start update chunk loading",
							`importScripts(${
								withCreateScriptUrl
									? `${RuntimeGlobals.createScriptUrl}(${RuntimeGlobals.publicPath} + ${RuntimeGlobals.getChunkUpdateScriptFilename}(chunkId))`
									: `${RuntimeGlobals.publicPath} + ${RuntimeGlobals.getChunkUpdateScriptFilename}(chunkId)`
							});`,
							'if(!success) throw new Error("Loading update chunk failed for unknown reason");'
						]),
						"}",
						"",
						generateJavascriptHMR("importScripts")
					])
				: "// no HMR",
			"",
			withHmrManifest
				? Template.asString([
						`${
							RuntimeGlobals.hmrDownloadManifest
						} = ${runtimeTemplate.basicFunction("", [
							'if (typeof fetch === "undefined") throw new Error("No browser support: need fetch API");',
							`return fetch(${RuntimeGlobals.publicPath} + ${
								RuntimeGlobals.getUpdateManifestFilename
							}()).then(${runtimeTemplate.basicFunction("response", [
								"if(response.status === 404) return; // no update available",
								'if(!response.ok) throw new Error("Failed to fetch update manifest " + response.statusText);',

View on GitHub (pinned to 318421ea8a)

Solutions

  1. Verify the hot-update chunk file exists and is non-empty at the URL the worker is importing from.
  2. Ensure publicPath and the worker's origin allow the script to be imported (same-origin, or proper CORS headers for importScripts).
  3. Clear the dev-server output directory and restart to regenerate clean chunks.
  4. Check the dev-server logs for a compile error on the update chunk that prevented the callback from being emitted.
Defensive patterns

Strategy: try-catch

Try / catch

// In the worker, guard HMR apply so a chunk that failed to register does not
// crash the worker — surface the error and skip this update cycle.
if (self.module && self.module.hot) {
  self.module.hot.dispose((data) => { /* save state */ });
  self.module.hot.accept(() => {
    try { /* re-import / re-init worker logic */ }
    catch (e) { console.error('HMR update failed, keeping previous code:', e); }
  });
}

Prevention

When it happens

Trigger: 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.

Common situations: 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.

Related errors


AI-assisted analysis of webpack/webpack@318421ea8a (2026-08-03). Data as JSON: /data/errors/ec8205fd184361ff.json. Report an issue: GitHub.