dotnet/runtime · error · Error
Failed to load Webcil module '${virtualPath}'. HTTP status:
Error message
Failed to load Webcil module '${virtualPath}'. HTTP status: ${(res as Response)?.status} ${(res as Response)?.statusText} What it means
Thrown by checkWebcilResponse() (src/native/libs/Common/JavaScript/host/assets.ts:83) when the awaited Response for a Webcil asset is falsy or res.ok === false. instantiateWebcilModule awaits this check before allocating the payload buffer, so a failed fetch surfaces as an HTTP status rather than a cryptic WebAssembly error.
Source
Thrown at src/native/libs/Common/JavaScript/host/assets.ts:86
instance = instantiated.instance;
} else {
const data = await res.arrayBuffer();
const instantiated = await WebAssembly.instantiate(data, imports);
instance = instantiated.instance;
}
finishWebcilInstance(instance, payloadPtr, payloadSize, tableEntries, virtualPath);
} catch (err) {
// Instantiation failed after the payload buffer was allocated; free it to avoid leaking
// unmanaged memory. (A grown R2R table cannot be shrunk back, but a failed R2R instantiate is fatal.)
_ems_._free(payloadPtr as any);
throw err;
}
}
async function checkWebcilResponse(webcilPromise: Promise<Response>, virtualPath: string): Promise<Response> {
const res = await webcilPromise;
if (!res || res.ok === false) {
throw new Error(`Failed to load Webcil module '${virtualPath}'. HTTP status: ${(res as Response)?.status} ${(res as Response)?.statusText}`);
}
return res;
}
// Allocates a 16-byte-aligned buffer for the Webcil payload. The pointer is heap memory that
// outlives the stack frame, so it can be passed as the imageBase import.
function allocWebcilPayload(payloadSize: number): number {
const sp = _ems_.stackSave();
try {
const ptrPtr = _ems_.stackAlloc(sizeOfPtr);
if (_ems_._posix_memalign(ptrPtr as any, 16, payloadSize)) {
throw new Error("posix_memalign failed for Webcil payload");
}
return _ems_.HEAPU32[ptrPtr as any >>> 2];
} finally {
_ems_.stackRestore(sp);
}
}View on GitHub (pinned to 60108ba66e)
Solutions
- Open the failing virtualPath URL directly in the browser/network tab and confirm it returns 200 with Content-Type application/wasm.
- Verify the deployed wwwroot/_framework contains the .wasm file and the application base / CDN prefix matches.
- If using a custom loadBootResourceCallback, return a Response that resolves ok:true (and the correct URL).
- Fix CORS so the response is usable (correct headers, no opaque no-cors response).
Example fix
// before
loadBootResource: (type, name, uri) => uri.replace('/cdn/', '/wrong/') // -> 404
// after
loadBootResource: (type, name, uri) => uri // return a resolvable URL Defensive patterns
Strategy: retry
Validate before calling
async function probeWebcil(url: string): Promise<boolean> {
const r = await fetch(url, { method: 'HEAD' });
return r.ok;
} Try / catch
try {
await instantiateWebcilModule(webcilPromise, memory, virtualPath, tableSize, payloadSize);
} catch (err) {
if (/Failed to load Webcil module/.test(String((err as Error).message))) {
// inspect the HTTP status embedded in the message; redeploy the asset or fix CORS
}
throw err;
} Prevention
- Deploy every webcil .wasm asset under _framework/ and verify with a HEAD request.
- Configure CORS so responses are usable (not opaque).
- Forward payloadSize/tableSize through any custom loadBootResourceCallback.
When it happens
Trigger: fetchWebcil() resolves the webcilPromise via loadResource, then instantiateWebcilModule calls checkWebcilResponse. A 404 for the .wasm file, a CDN error (5xx), a CORS block producing an opaque response, or a custom loadBootResourceCallback returning a failed Response all trigger this.
Common situations: Asset not published/deployed (404); wrong application base / CDN path; CORS misconfiguration returning an error response; integrity check failure promoted to a non-OK response; a custom loadBootResourceCallback returning the wrong URL.
Related errors
- Failed to load WebAssembly module. HTTP status: ${res?.statu
- BrowserHttpWriteStream.Rejected
- Failed to load resource '${asset.name}' from '${asset.resolv
- BrowserHttpWriteStream.Rejected
- Failed to download {url}, Status Code: {response.status}
AI-assisted analysis of dotnet/runtime@60108ba66e (2026-08-10).
Data as JSON: /api/errors/c9d8f9bdffb56510.
Report an issue: GitHub.