diff --git a/crates/cli-support/src/js/mod.rs b/crates/cli-support/src/js/mod.rs index 9d404113..cd3b4ba1 100644 --- a/crates/cli-support/src/js/mod.rs +++ b/crates/cli-support/src/js/mod.rs @@ -536,13 +536,19 @@ impl<'a> Context<'a> { if (typeof WebAssembly.instantiateStreaming === 'function') {{ result = WebAssembly.instantiateStreaming(response, imports) .catch(e => {{ - console.warn(\"`WebAssembly.instantiateStreaming` failed. Assuming this is \ - because your server does not serve wasm with \ - `application/wasm` MIME type. Falling back to \ - `WebAssembly.instantiate` which is slower. Original \ - error:\\n\", e); return response - .then(r => r.arrayBuffer()) + .then(r => {{ + if (r.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); + return r.arrayBuffer(); + }} else {{ + throw e; + }} + }}) .then(bytes => WebAssembly.instantiate(bytes, imports)); }}); }} else {{