{"record":{"id":"ddd140f06e40fcb6","repo":"pbakaus/impeccable","slug":"webassembly-instantiatestreaming-failed-because","errorCode":null,"errorMessage":"`WebAssembly.instantiateStreaming` failed because your server does not serve Wasm with `application/wasm` MIME type. Falling back to `WebAssembly.instantiate` which is slower. Original error:\n","messagePattern":"`WebAssembly\\.instantiateStreaming` failed because your server does not serve Wasm with `application/wasm` MIME type\\. Falling back to `WebAssembly\\.instantiate` which is slower\\. Original error:\n","errorType":"console","errorClass":null,"httpStatus":null,"severity":"warning","filePath":"crates/live/assets/detect-antipatterns-browser.js","lineNumber":2391,"sourceCode":"        cachedUint32ArrayMemory0 = null;\n        cachedUint8ArrayMemory0 = null;\n        return wasm;\n    }\n\n    async function __wbg_load(module, imports) {\n        if (typeof Response === 'function' && module instanceof Response) {\n            if (!module.ok) {\n                throw new Error(`failed to fetch Wasm: ${module.status} ${module.statusText} fetching '${module.url}'`);\n            }\n\n            if (typeof WebAssembly.instantiateStreaming === 'function') {\n                try {\n                    return await WebAssembly.instantiateStreaming(module, imports);\n                } catch (e) {\n                    const validResponse = expectedResponseType(module.type);\n\n                    if (validResponse && module.headers.get('Content-Type') !== 'application/wasm') {\n                        console.warn(\"`WebAssembly.instantiateStreaming` failed because your server does not serve Wasm with `application/wasm` MIME type. Falling back to `WebAssembly.instantiate` which is slower. Original error:\\n\", e);\n\n                    } else { throw e; }\n                }\n            }\n\n            const bytes = await module.arrayBuffer();\n            return await WebAssembly.instantiate(bytes, imports);\n        } else {\n            const instance = await WebAssembly.instantiate(module, imports);\n\n            if (instance instanceof WebAssembly.Instance) {\n                return { instance, module };\n            } else {\n                return instance;\n            }\n        }\n\n        function expectedResponseType(type) {","sourceCodeStart":2373,"sourceCodeEnd":2409,"githubUrl":"https://github.com/pbakaus/impeccable/blob/2bc2879276c1f321a53c4ca99d3371e411329b52/crates/live/assets/detect-antipatterns-browser.js#L2373-L2409","documentation":"This is a console warning emitted when WebAssembly.instantiateStreaming fails because the Wasm response was not served with the `application/wasm` Content-Type. The embedder falls back to the slower WebAssembly.instantiate(arrayBuffer) path and logs the original error. The code still works, just with a slower compile path.","triggerScenarios":"WebAssembly.instantiateStreaming(fetch(...)) receives a valid 200 response whose headers Content-Type is not `application/wasm`, so streaming instantiation throws and the catch block warns before falling back.","commonSituations":"Static file servers (python http.server, some dev servers, misconfigured nginx/Apache/S3/CDN) serving .wasm as application/octet-stream or text/plain; missing mime.types entry; CDN or proxy rewriting Content-Type headers.","solutions":["Configure the server/CDN to serve .wasm files with Content-Type: application/wasm (e.g. nginx `types { application/wasm wasm; }`, S3/CloudFront metadata update).","Verify with `curl -I https://host/file.wasm` that Content-Type is application/wasm.","If the server cannot be fixed, ignore the warning or pre-fetch bytes and call WebAssembly.instantiate(bytes) directly to avoid the failed streaming attempt."],"exampleFix":"// nginx before\n# default: .wasm served as application/octet-stream\n// nginx after\ntypes {\n    application/wasm wasm;\n}","handlingStrategy":"fallback","validationCode":"const res = await fetch(url);\nif (res.ok && res.headers.get('Content-Type') !== 'application/wasm') {\n  console.warn('Wasm not served as application/wasm; streaming instantiate will fall back');\n}","typeGuard":"function isWasmResponse(res) { return res instanceof Response && (res.headers.get('Content-Type') || '').includes('application/wasm'); }","tryCatchPattern":"try {\n  return await WebAssembly.instantiateStreaming(res, imports);\n} catch (e) {\n  if ((res.headers.get('Content-Type') || '') !== 'application/wasm') {\n    console.warn('falling back to WebAssembly.instantiate', e);\n    return WebAssembly.instantiate(await res.arrayBuffer(), imports);\n  }\n  throw e;\n}","preventionTips":["Add application/wasm to server MIME config in every environment (dev, staging, CDN).","Add a CI check that curls a deployed .wasm file and asserts the Content-Type.","Prefer explicit arrayBuffer + WebAssembly.instantiate when you control the fetch and know the server is misconfigured."],"tags":["webassembly","mime-type","http-headers","browser"],"backgroundTag":"unsupported-content-type","analyzedSha":"2bc2879276c1f321a53c4ca99d3371e411329b52","analyzedAt":"2026-09-08T04:51:14.109Z","contentChangedAt":"2026-09-08T04:51:14.109Z","schemaVersion":2},"datasetVersion":"2026-09-14T05:17:10.506Z"}