dotnet/runtime · critical · Error
Failed to load WebAssembly module. HTTP status
Error message
Failed to load WebAssembly module. HTTP status: ${res?.status} ${res?.statusText} What it means
Thrown by checkResponseOk() inside instantiateWasm() (src/native/libs/Common/JavaScript/host/assets.ts:244) when the Response for the main runtime wasm (dotnet.wasm) is falsy or res.ok === false. instantiateWasm awaits this before streaming/arrayBuffer instantiation, so a failed download of the core wasm binary surfaces as a clear HTTP error rather than a raw WebAssembly compile failure.
Solutions
- Confirm dotnet.wasm is deployed under _framework/ and reachable at the resolved URL with HTTP 200 and Content-Type application/wasm.
- Fix CORS headers and the application base so the response is usable (avoid opaque no-cors responses).
- If using a custom loadBootResourceCallback for the wasm, return a Response that resolves ok:true.
- Clear any stale service worker that may be serving a cached error page for dotnet.wasm.
Example fix
// before
loadBootResource: (t, n, uri) => fetch(uri, { mode: 'no-cors' }) // opaque -> res.ok === false
// after
loadBootResource: (t, n, uri) => fetch(uri) // proper CORS Response, ok:true Defensive patterns
Strategy: retry
Validate before calling
async function probeWasm(url: string): Promise<boolean> {
const r = await fetch(url, { method: 'HEAD' });
return r.ok && (r.headers.get('Content-Type') || '').includes('application/wasm');
} Try / catch
try {
await instantiateWasm(wasmBinaryPromise, imports);
} catch (err) {
if (/Failed to load WebAssembly module/.test(String((err as Error).message))) {
// redeploy dotnet.wasm, fix CORS, or clear a stale service worker
}
throw err;
} Prevention
- Deploy dotnet.wasm with Content-Type application/wasm and correct CORS.
- Return a usable (non-opaque) Response from any custom loadBootResourceCallback.
- Bust stale service-worker caches when redeploying.
When it happens
Trigger: fetchMainWasm() resolves wasmBinaryPromise via loadResource; instantiateWasm awaits checkResponseOk(wasmPromise). A 404 for dotnet.wasm, a 5xx, a CORS-blocked response, or an opaque no-cors Response triggers the throw; the catch then calls dotnetApi.exit(1, err).
Common situations: dotnet.wasm not deployed (404); wrong content path/CDN; CORS misconfiguration; integrity mismatch surfaced as a non-OK response; a service worker returning an error page; the wrong MIME type forcing the streaming path to fail.
Related errors
- Failed to load Webcil module
- BrowserHttpWriteStream.Rejected
- BrowserHttpWriteStream.Rejected
- Failed to download , Status Code
- Failed to load resource
AI-assisted analysis of dotnet/runtime@60108ba66e (2026-08-10).
Data as JSON: /api/errors/e4371d07faaea4c5.
Report an issue: GitHub.
Appendix: source
Thrown at src/native/libs/Common/JavaScript/host/assets.ts:248
const data = await res.arrayBuffer();
module = await WebAssembly.compile(data);
instance = await WebAssembly.instantiate(module, imports);
} else {
const instantiated = await WebAssembly.instantiateStreaming(wasmPromise, imports);
instance = instantiated.instance;
module = instantiated.module;
}
return { instance, module };
} catch (err) {
_ems_.dotnetApi.exit(1, err);
throw err;
}
async function checkResponseOk(wasmPromise: Promise<Response> | undefined): Promise<Response & { isStreamingOk?: boolean }> {
_ems_.dotnetAssert.check(wasmPromise, "WASM binary promise was not initialized");
const res = (await wasmPromise) as Response & { isStreamingOk?: boolean };
if (!res || res.ok === false) {
throw new Error(`Failed to load WebAssembly module. HTTP status: ${res?.status} ${res?.statusText}`);
}
res.isStreamingOk = typeof globalThis.Response === "function" && res instanceof globalThis.Response;
const contentType = res.headers && res.headers.get ? res.headers.get("Content-Type") : undefined;
if (_ems_.ENVIRONMENT_IS_WEB && contentType !== "application/wasm") {
_ems_.dotnetLogger.warn("WebAssembly resource does not have the expected content type \"application/wasm\", so falling back to slower ArrayBuffer instantiation.");
res.isStreamingOk = false;
}
return res;
}
}
View on GitHub (pinned to 60108ba66e)