Commit 11a4b16
fix(js): always fall back to non-streaming WebAssembly.instantiate
wasm-bindgen generates code that rethrows when
WebAssembly.instantiateStreaming fails and Content-Type is
application/wasm. This breaks in environments where fetch() returns a
Proxy-wrapped Response (e.g. OpenTelemetry instrumentation-fetch) that
passes JS `instanceof Response` but fails the browser's internal slot
checks in WebAssembly.instantiateStreaming/compileStreaming.
Add a post-build step that patches the generated __wbg_load function to
always fall back to the ArrayBuffer path (response.arrayBuffer() +
WebAssembly.instantiate) instead of conditionally rethrowing. The
streaming path is purely an optimization; the ArrayBuffer path is always
correct.
Co-Authored-By: Claude Opus 4.6 <noreply@anthropic.com>1 parent e9dff15 commit 11a4b16
1 file changed
+53
-0
lines changed| Original file line number | Diff line number | Diff line change | |
|---|---|---|---|
| |||
10 | 10 | | |
11 | 11 | | |
12 | 12 | | |
| 13 | + | |
13 | 14 | | |
14 | 15 | | |
15 | 16 | | |
| |||
32 | 33 | | |
33 | 34 | | |
34 | 35 | | |
| 36 | + | |
| 37 | + | |
| 38 | + | |
| 39 | + | |
| 40 | + | |
| 41 | + | |
| 42 | + | |
| 43 | + | |
| 44 | + | |
| 45 | + | |
| 46 | + | |
| 47 | + | |
| 48 | + | |
| 49 | + | |
| 50 | + | |
| 51 | + | |
| 52 | + | |
| 53 | + | |
| 54 | + | |
| 55 | + | |
| 56 | + | |
| 57 | + | |
| 58 | + | |
| 59 | + | |
| 60 | + | |
| 61 | + | |
| 62 | + | |
| 63 | + | |
| 64 | + | |
| 65 | + | |
| 66 | + | |
| 67 | + | |
| 68 | + | |
| 69 | + | |
| 70 | + | |
| 71 | + | |
| 72 | + | |
| 73 | + | |
| 74 | + | |
| 75 | + | |
| 76 | + | |
| 77 | + | |
| 78 | + | |
| 79 | + | |
| 80 | + | |
| 81 | + | |
| 82 | + | |
| 83 | + | |
| 84 | + | |
| 85 | + | |
| 86 | + | |
| 87 | + | |
35 | 88 | | |
36 | 89 | | |
37 | 90 | | |
| |||
0 commit comments