pbakaus/impeccable · warning

`WebAssembly.instantiateStreaming` failed because your serve

Error message

`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:

What it means

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.

Source

Thrown at crates/live/assets/detect-antipatterns-browser.js:2391

        cachedUint32ArrayMemory0 = null;
        cachedUint8ArrayMemory0 = null;
        return wasm;
    }

    async function __wbg_load(module, imports) {
        if (typeof Response === 'function' && module instanceof Response) {
            if (!module.ok) {
                throw new Error(`failed to fetch Wasm: ${module.status} ${module.statusText} fetching '${module.url}'`);
            }

            if (typeof WebAssembly.instantiateStreaming === 'function') {
                try {
                    return await WebAssembly.instantiateStreaming(module, imports);
                } catch (e) {
                    const validResponse = expectedResponseType(module.type);

                    if (validResponse && module.headers.get('Content-Type') !== 'application/wasm') {
                        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);

                    } else { throw e; }
                }
            }

            const bytes = await module.arrayBuffer();
            return await WebAssembly.instantiate(bytes, imports);
        } else {
            const instance = await WebAssembly.instantiate(module, imports);

            if (instance instanceof WebAssembly.Instance) {
                return { instance, module };
            } else {
                return instance;
            }
        }

        function expectedResponseType(type) {

View on GitHub (pinned to 2bc2879276)

Solutions

  1. Configure the server/CDN to serve .wasm files with Content-Type: application/wasm (e.g. nginx `types { application/wasm wasm; }`, S3/CloudFront metadata update).
  2. Verify with `curl -I https://host/file.wasm` that Content-Type is application/wasm.
  3. 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.

Example fix

// nginx before
# default: .wasm served as application/octet-stream
// nginx after
types {
    application/wasm wasm;
}
Defensive patterns

Strategy: fallback

Validate before calling

const res = await fetch(url);
if (res.ok && res.headers.get('Content-Type') !== 'application/wasm') {
  console.warn('Wasm not served as application/wasm; streaming instantiate will fall back');
}

Type guard

function isWasmResponse(res) { return res instanceof Response && (res.headers.get('Content-Type') || '').includes('application/wasm'); }

Try / catch

try {
  return await WebAssembly.instantiateStreaming(res, imports);
} catch (e) {
  if ((res.headers.get('Content-Type') || '') !== 'application/wasm') {
    console.warn('falling back to WebAssembly.instantiate', e);
    return WebAssembly.instantiate(await res.arrayBuffer(), imports);
  }
  throw e;
}

Prevention

When it happens

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

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

Related errors


AI-assisted analysis of pbakaus/impeccable@2bc2879276 (2026-09-08). Data as JSON: /api/errors/ddd140f06e40fcb6. Report an issue: GitHub.