Repository navigation
Fix hanging WebAssembly compiles and add compileStreaming() - #8730
littledivy wants to merge 3 commits into
Conversation
There was a problem hiding this comment.
Superseded by the review of
40d7da44.
This review, of 50461f9c
💬 Approved with comments — One WARNING: under webassembly_dynamic_compilation, the synchronous WebAssembly.Module constructor ignores an embedder's asynchronous refusal. It sits behind an experimental flag, and the default embedder accepts every module. There is also one INFO test nit.
Findings: 1 warning · 1 info (2 are inline comments on the diff)
The decision is advisory: this review is a comment and never approves, blocks or requests changes on the pull request.
🔧 Fix with your agent
Paste the following into your coding agent to investigate and fix these issues.
Fix the following code review issues found in pull request #8730.
Before making changes, review each issue and present a brief summary table:
- For each finding, state whether you agree, disagree, or need clarification
- If you disagree (e.g., the fix would require disproportionate changes
for minimal ROI, or the finding is factually incorrect), explain why
- If you need to clarify something before deciding, ask those questions
- Then share your plan for which issues to tackle and in what order
## WARNING (1)
### [Security] Under webassembly_dynamic_compilation, `new WebAssembly.Module()` ignores an embedder's asynchronous refusal, so the Worker can run a module the embedder later rejects.
- **File:** src/workerd/api/wasm-api/dynamic.rs:119
## INFO (1)
### [Code Quality] `ok(Date.now() >= start)` is always true and does not check anything about the IoContext.
- **File:** src/workerd/api/tests/unsafe-test.js:108
🔒 Security: ⚠️ 1 warning
The constructor path does not apply the embedder's asynchronous refusal
Recommendation: 📝 Minor Comments
- [WARNING] Under webassembly_dynamic_compilation,
new WebAssembly.Module()ignores an embedder's asynchronous refusal, so the Worker can run a module the embedder later rejects. (src/workerd/api/wasm-api/dynamic.rs:119)
View full review
The embedder's accept/refuse gate is incomplete for new WebAssembly.Module(bytes) (src/workerd/api/wasm-api/dynamic.rs:113-131)
compile(),instantiate()and the streaming functions wait forsubmitWasmModule()to resolve before the Worker gets the module.- The constructor compiles right away. A rejected submission promise fails only a background task of the request.
- So the Worker can run
new WebAssembly.Instance(new WebAssembly.Module(bytes))before the embedder decides, and keep running after the embedder refuses. io-channels.hdocuments this, but thewebassembly_dynamic_compilationflag text says the embedder "can refuse" each module without that qualification.wasm-dynamic-compile-test.c++tests only a synchronous refusal on the constructor path.
The default embedder accepts every module, so nothing in this repository is affected today.
📋 Code Quality: 💬 1 info
One vacuous assertion in a test
Recommendation: 💬 Optional Nits
- [INFO]
ok(Date.now() >= start)is always true and does not check anything about the IoContext. (src/workerd/api/tests/unsafe-test.js:108)
View full review
asyncWasmCompileContinuesInIoContext contains an assertion that can never fail.
✅ All other checks passed
📖 AGENTS.md: ✅ LGTM
No AGENTS.md issues found.
⚡ Performance: ✅ LGTM
No performance concerns. Posting a foreground task takes no lock while nothing is waiting.
📝 Documentation: ✅ LGTM
No documentation issues found.
Reviewed commit: 50461f9c
50461f9 to
40d7da4
Compare
There was a problem hiding this comment.
Superseded by the review of
544289f3.
This review, of 40d7da44
💬 Approved with comments — The earlier constructor-refusal gap is now part of the documented submitWasmModule() contract, and the default embedder accepts every module. One INFO remains: the flag text could carry the same qualification.
Findings: 1 info (1 is an inline comment on the diff)
The decision is advisory: this review is a comment and never approves, blocks or requests changes on the pull request.
🔒 Security: 💬 1 info
The constructor's synchronous-only refusal is now documented in io-channels.h; the flag text doesn't mention it yet.
Recommendation: 💬 Optional Nits
- [INFO] The webassembly_dynamic_compilation flag text doesn't say that new WebAssembly.Module() honours only a synchronous refusal from the embedder. (
src/workerd/io/compatibility-date.capnp:1894)
View full review
src/workerd/api/wasm-api/dynamic.rs:113-131:new WebAssembly.Module()honours only a synchronous throw fromsubmitWasmModule(). An asynchronous rejection fails a background task of the request, but the Worker keeps the module.src/workerd/io/io-channels.h:255-263now states this limit and tells embedders that must see every module to throw when they can't decide at once. That makes it part of the interface contract. The default embedder accepts every module.src/workerd/io/compatibility-date.capnp:1894-1895: the flag text says the embedder "can refuse" each module, but it doesn't say that the constructor honours only a synchronous refusal.
✅ All other checks passed
📖 AGENTS.md: ✅ LGTM
No AGENTS.md issues found.
📋 Code Quality: ✅ LGTM
asyncWasmCompileContinuesInIoContext now calls setTimeout() after awaiting the compile, and setTimeout() throws outside an IoContext, so the always-true assertion is gone. Nothing else in the diff needs changing.
⚡ Performance: ✅ LGTM
No performance concerns.
📝 Documentation: ✅ LGTM
No documentation issues found.
Reviewed commit: 40d7da44
40d7da4 to
544289f
Compare
There was a problem hiding this comment.
Superseded by the review of
ea68b39e.
This review, of 544289f3
💬 Approved with comments — The earlier flag-text note is fixed. Two INFO notes remain: the submitWasmModule() comment doesn't match how streaming compiles work, and one flag-comment line needs reflowing.
Findings: 2 info (2 are inline comments on the diff)
The decision is advisory: this review is a comment and never approves, blocks or requests changes on the pull request.
📋 Code Quality: 💬 2 info
Two minor notes: the embedder contract wording for streaming compiles, and one unwrapped comment line.
Recommendation: 💬 Optional Nits
- [INFO] The submitWasmModule() contract says the embedder sees the bytes before the module compiles, but streaming compiles start before the embedder gets the bytes. (
src/workerd/io/io-channels.h:256) - [INFO] One line of the webassemblyDynamicCompilation flag comment runs past the wrap width. (
src/workerd/io/compatibility-date.capnp:1897)
View full review
src/workerd/io/io-channels.h:255-256: the comment says the embedder gets each module's bytes "before the module compiles". That isn't true for streaming.WasmStreamingSink::pushpasses each chunk to V8's streaming compiler (streaming.rs:72), anddynamic::submit()runs only infinish()(streaming.rs:95). The Worker still can't get the module before the embedder accepts it.src/workerd/io/compatibility-date.capnp:1897: this line of the flag comment wasn't reflowed to the file's wrap width.
✅ All other checks passed
🔒 Security: ✅ LGTM
The webassembly_dynamic_compilation flag text (src/workerd/io/compatibility-date.capnp:1891-1898) now says that new WebAssembly.Module() can't wait, and that if the embedder refuses the module later, the request is aborted and the isolate condemned. That matches submit_from_constructor in src/workerd/api/wasm-api/dynamic.rs and the submitWasmModule() contract in src/workerd/io/io-channels.h.
📖 AGENTS.md: ✅ LGTM
No AGENTS.md issues found.
⚡ Performance: ✅ LGTM
No performance concerns.
📝 Documentation: ✅ LGTM
No documentation issues found.
Reviewed commit: 544289f3
544289f to
ea68b39
Compare
There was a problem hiding this comment.
Superseded by the review of
c7ddba17.
This review, of ea68b39e
✅ Approved — Both earlier INFO notes (the submitWasmModule() comment and the flag-comment wrap) are fixed, and no new issues were found.
The decision is advisory: this review is a comment and never approves, blocks or requests changes on the pull request.
✅ All checks passed
🔒 Security: ✅ LGTM
The reworded flag text and the submitWasmModule() contract agree with each other: the Worker gets a module only after the embedder accepts it, and a late refusal of a new WebAssembly.Module() aborts the request and condemns the isolate. Neither change weakens a security boundary.
📖 AGENTS.md: ✅ LGTM
No AGENTS.md issues found.
📋 Code Quality: ✅ LGTM
The submitWasmModule() contract (src/workerd/io/io-channels.h:255-264) now matches the streaming path. The flag comments in compatibility-date.capnp fit the wrap width. No new correctness problems were found in the rest of the change.
⚡ Performance: ✅ LGTM
No performance concerns.
📝 Documentation: ✅ LGTM
No documentation issues found.
Reviewed commit: ea68b39e
|
We need to carefully evaluate whether we want to enable @danlapid @guybedford, thoughts? |
guybedford
left a comment
There was a problem hiding this comment.
Agree with @jasnell. While we're ok with the security posture now and are planning to enable this, I think webassembly_dynamic_compilation should be a separate PR, gated on wasm eval.
|
Sorry I see this is compat flagged as experimental - that does seem fine to me. I don't see why we need two flags though, why not just |
ea68b39 to
c7ddba1
Compare
There was a problem hiding this comment.
Superseded by the review of
b15df69e.
This review, of c7ddba17
💬 Approved with comments — One WARNING: under the experimental webassembly_dynamic_compilation flag, calling WebAssembly.Module(bytes) without new submits the bytes, and a later refusal by the embedder condemns the isolate even though no module was compiled. No other issues found.
Findings: 1 warning (1 is an inline comment on the diff)
The decision is advisory: this review is a comment and never approves, blocks or requests changes on the pull request.
🔧 Fix with your agent
Paste the following into your coding agent to investigate and fix these issues.
Fix the following code review issues found in pull request #8730.
Before making changes, review each issue and present a brief summary table:
- For each finding, state whether you agree, disagree, or need clarification
- If you disagree (e.g., the fix would require disproportionate changes
for minimal ROI, or the finding is factually incorrect), explain why
- If you need to clarify something before deciding, ask those questions
- Then share your plan for which issues to tackle and in what order
## WARNING (1)
### [Code Quality] Under webassembly_dynamic_compilation, `WebAssembly.Module(bytes)` without `new` submits the bytes before V8 throws its TypeError, and a later refusal by the embedder aborts the request and condemns the isolate even though nothing was compiled (reproduced by @guybedford [approver]).
- **File:** src/workerd/api/wasm-api/dynamic.rs:119
📋 Code Quality: ⚠️ 1 warning
Calling WebAssembly.Module(bytes) without new submits bytes that never compile, and a later refusal by the embedder still condemns the isolate.
Recommendation: 📝 Minor Comments
- [WARNING] Under webassembly_dynamic_compilation,
WebAssembly.Module(bytes)withoutnewsubmits the bytes before V8 throws its TypeError, and a later refusal by the embedder aborts the request and condemns the isolate even though nothing was compiled (reproduced by @guybedford [approver]). (src/workerd/api/wasm-api/dynamic.rs:119)
View full review
submit_from_constructor can't tell new WebAssembly.Module() from a plain call (src/workerd/api/wasm-api/dynamic.rs:115-139, ffi.c++:47)
V8 calls the WasmModuleCallback before it checks IsConstructCall(). The shim's wasmModuleCallback(isolate, source) gets only source, so it can't tell whether the call used new. As a result, WebAssembly.Module(bytes) without new does two things:
- it submits the bytes and schedules the
await_io_and_runcontinuation; - V8 then throws a TypeError.
If the embedder later refuses those bytes, abort_isolate_for_refused_module() runs, the request is aborted and the isolate is condemned, although no module exists. @guybedford [approver] reproduced this in wasm-dynamic-compile-test.c++. This code hasn't changed since the earlier review, which missed it.
Possible fixes:
- wrap
WebAssembly.Modulein the shim and checknew.targetbefore the call reaches V8; - pass the call kind through to the callback;
- only condemn the isolate if V8 actually produced a module.
A regression test for the non-new call would also help.
✅ All other checks passed
🔒 Security: ✅ LGTM
No security issues found. The eval() restriction is unchanged, and every module compiled under the dynamic-compilation flag goes to the embedder before the Worker can use it.
📖 AGENTS.md: ✅ LGTM
No AGENTS.md issues found.
⚡ Performance: ✅ LGTM
No performance concerns.
📝 Documentation: ✅ LGTM
No documentation issues found.
Reviewed commit: c7ddba17
c7ddba1 to
b15df69
Compare
There was a problem hiding this comment.
Superseded by the review of
17825bda.
This review, of b15df69e
💬 Approved with comments — The earlier WARNING (a plain WebAssembly.Module(bytes) call could condemn the isolate) is fixed and covered by a test. Only a doc-comment suggestion remains.
Findings: 1 suggestion (1 is an inline comment on the diff)
The decision is advisory: this review is a comment and never approves, blocks or requests changes on the pull request.
📋 Code Quality: 💬 1 suggestion
The WebAssembly.Module()-without-new issue is fixed and tested; one doc-comment nit remains.
Recommendation: 💬 Optional Nits
- [SUGGESTION] The doc comment on
submit_from_constructorhas an overlong line and a hard-to-follow first sentence left from the fix. (src/workerd/api/wasm-api/dynamic.rs:108)
View full review
The shim's Module wrapper (src/workerd/io/wasm-instantiate-shim.js) throws the TypeError when new.target is undefined, before the WasmModuleCallback runs. Otherwise it forwards to the native constructor with Reflect.construct. The wrapper keeps the prototype chain, the static methods and length. New tests in wasm-dynamic-compile-test.c++ cover a plain call with a refusing embedder and subclassing.
Remaining nit: the doc comment on submit_from_constructor in dynamic.rs runs past the wrap width, and its first sentence is hard to follow.
✅ All other checks passed
🔒 Security: ✅ LGTM
No security issues found. eval() stays disallowed, and every module compiled under the dynamic-compilation flag goes to the embedder, which can refuse it.
📖 AGENTS.md: ✅ LGTM
No AGENTS.md issues found.
⚡ Performance: ✅ LGTM
No performance concerns.
📝 Documentation: ✅ LGTM
No documentation issues found.
Reviewed commit: b15df69e
b15df69 to
17825bd
Compare
There was a problem hiding this comment.
Superseded by the review of
b8d130fa.
This review, of 17825bda
💬 Approved with comments — No correctness or security problems. One optional doc-comment nit remains in dynamic.rs.
Findings: 1 suggestion (1 is an inline comment on the diff)
The decision is advisory: this review is a comment and never approves, blocks or requests changes on the pull request.
📋 Code Quality: 💬 1 suggestion
One doc-comment nit remains in dynamic.rs.
Recommendation: 💬 Optional Nits
- [SUGGESTION] The doc comment on
submit_from_constructorbreaks mid-sentence at an uneven width. (src/workerd/api/wasm-api/dynamic.rs:112)
View full review
The refusal handling in submit_from_constructor is consistent with the rule against throwing while execution is terminating. The only remaining nit is the doc comment above it: one paragraph breaks mid-sentence at an uneven width.
✅ All other checks passed
🔒 Security: ✅ LGTM
No security issues found. submit_source copies the bytes synchronously, right before V8 compiles them, so the embedder sees exactly the bytes V8 compiles. A refused module either throws at once or condemns the isolate and aborts the request.
📖 AGENTS.md: ✅ LGTM
No AGENTS.md issues found.
⚡ Performance: ✅ LGTM
No performance concerns.
📝 Documentation: ✅ LGTM
No documentation issues found.
Reviewed commit: 17825bda
17825bd to
b8d130f
Compare
There was a problem hiding this comment.
Superseded by the review of
4fc84772.
This review, of b8d130fa
✅ Approved — No findings at this commit. The only change since the last review fixes the earlier doc-comment nit in dynamic.rs and doesn't change behaviour.
The decision is advisory: this review is a comment and never approves, blocks or requests changes on the pull request.
✅ All checks passed
🔒 Security: ✅ LGTM
No security issues found. The shim makes WebAssembly.Module throw when called without new, before V8 reads the bytes, so the submit callback only sees modules that V8 goes on to compile.
📖 AGENTS.md: ✅ LGTM
No AGENTS.md issues found.
📋 Code Quality: ✅ LGTM
The doc comment on submit_from_constructor (src/workerd/api/wasm-api/dynamic.rs:107-115) now wraps at a normal width. Behaviour is the same as before: the code checks for termination before it throws, and when the embedder refuses a module it condemns the isolate and aborts the request. Ordinals 210 and 211 of the compatibility flags are unique.
⚡ Performance: ✅ LGTM
No performance concerns. The module bytes are copied once per compile, and only when dynamic compilation is allowed. The embedder needs its own copy, so this copy can't be avoided.
📝 Documentation: ✅ LGTM
No documentation issues found.
Reviewed commit: b8d130fa
b8d130f to
4fc8477
Compare
There was a problem hiding this comment.
💬 Approved with comments — The only change since the last review is the two experimental compatibility flags, and they're correct. One INFO: the doc comment on webassemblyStreaming describes the null-body case differently from the shim.
Findings: 1 info (1 is an inline comment on the diff)
The decision is advisory: this review is a comment and never approves, blocks or requests changes on the pull request.
📝 Documentation: 💬 1 info
The webassemblyStreaming doc comment says a Response must have a body, but the shim accepts a null body.
Recommendation: 💬 Optional Nits
- [INFO] The webassemblyStreaming doc comment says a Response without a body is rejected with a TypeError; the shim actually compiles zero bytes and rejects with a CompileError. (
src/workerd/io/compatibility-date.capnp:1895)
View full review
src/workerd/io/compatibility-date.capnp:1895: the comment says streaming compilation rejects with a TypeError unless the Response has a body. The shim accepts a null body and passes zero bytes to V8, which rejects the empty module with a CompileError (wasm-instantiate-shim.js:329-355).
✅ All other checks passed
🔒 Security: ✅ LGTM
Both new flags are experimental and off by default, so Workers that don't opt in get no new attack surface. Whether dynamic compilation should ship separately, gated on wasm eval, is a product decision for the maintainers.
📖 AGENTS.md: ✅ LGTM
No issues found.
📋 Code Quality: ✅ LGTM
The flag ordinals @211 and @212 are unique and come after udpIngress @210. The flag names match where they're used in the Rust crate, worker.c++, io-channels.h, the shim, the tests and the WPT BUILD. The shim's Module wrapper throws on a call without new before V8's WasmModuleCallback runs (wasm-instantiate-shim.js:174-179).
⚡ Performance: ✅ LGTM
The only change since the last review is a flag definition and its doc comment, which has no runtime effect.
Reviewed commit: 4fc84772
4fc8477 to
0f5cb4d
Compare
There was a problem hiding this comment.
Superseded by the review of
882d1a00.
This review, of 0f5cb4d0
✅ Approved — The only change since the last review is the two experimental compatibility flags. They are correct, and the earlier doc-comment note is fixed.
The decision is advisory: this review is a comment and never approves, blocks or requests changes on the pull request.
✅ All checks passed
🔒 Security: ✅ LGTM
Both new flags are experimental and off by default, so Workers that don't opt in get nothing new to attack. Whether dynamic compilation should ship separately, gated on wasm eval, is a product decision for the maintainers.
📖 AGENTS.md: ✅ LGTM
No issues found.
📋 Code Quality: ✅ LGTM
- The flag ordinals
@211and@212are unique and come afterudpIngress @210. - The flag names match every place they are used.
- The shim's
Modulewrapper throws on a call withoutnewbefore V8'sWasmModuleCallbackruns (wasm-instantiate-shim.js:200-202).
⚡ Performance: ✅ LGTM
The change since the last review is flag declarations and their doc comments, which cost nothing at runtime.
📝 Documentation: ✅ LGTM
The webassemblyStreaming comment now says a Response without a body compiles no bytes and is rejected with a CompileError, which matches the shim.
Reviewed commit: 0f5cb4d0
V8 finishes an async WebAssembly compile on a foreground task, but posting a task doesn't wake the KJ event loop, so nothing runs it until some other event comes along. Code waiting for such a task has nothing to wait on. In this patch each IsolateBase gets a ForegroundTaskSignal, which the platform wrapper's per-isolate runners notify whenever V8 posts an immediate foreground task. Posts advance an epoch, so a waiter that read the epoch before starting the work can't miss one, and a post takes no lock while nothing waits. The runners are created once per isolate and priority. IsolateBase also gets an allowWasmCodeGenerationHook, which lets the embedder allow WebAssembly compilation where eval() stays disallowed. Nothing sets it yet. The notifying runner adds about 7 ns to each foreground post (opt build, Linux, against a runner that does nothing).
WebAssembly.compile() and instantiate() with bytes could hang a request: V8 settles their promises from a foreground task that nothing ran until some other event came along, and then outside the request, so the promise's reactions couldn't start I/O. Workers also had no WebAssembly.compileStreaming() or instantiateStreaming(), which V8 provides only when the embedder sets a streaming callback, and they couldn't compile a module they fetch while handling a request at all. In this patch a new Rust crate, wasm-api, adds these to V8's WebAssembly, and Worker::Api gets installWasm() and newWasmCompileFunction() so WorkerdApi installs it in each isolate: - The shim calls compile(), instantiate() and the streaming functions through a Rust compileWasm(). When V8's promise is pending in a request, its reaction only notifies the isolate's foreground task signal, and the request runs V8's foreground tasks inside itself whenever V8 posts one until V8's promise settles. The Worker gets V8's result in the request. If the request goes away first, nothing is left waiting. Compiles at startup, instantiating a compiled Module and promises V8 already settled pass through. - Under the experimental webassembly_streaming flag, the shim checks the Response as the WebAssembly Web API specifies and reads its body into a Rust sink that feeds V8's streaming compiler. A body error aborts the compilation with that error, and a compilation dropped before its body ends is aborted from the isolate's next foreground task. Without the flag, both functions are removed from WebAssembly. - Under the experimental webassembly_dynamic_compilation flag, a Worker may compile WebAssembly while handling a request. eval() stays disallowed, and a copy of each module's bytes goes to IoChannelFactory::submitWasmModule() first, which can refuse it. Compiles settle only once the embedder accepts the module. The bytes are charged to the isolate as external memory until the embedder drops them. new WebAssembly.Module() can't wait, so its submission finishes as a task of the request, and if the embedder refuses the module then, the request is aborted and the isolate condemned, since the Worker may have kept the module anywhere. The default accepts every module. Workers that compile asynchronously today, at startup or under unsafe eval, see two changes. WebAssembly.compile is now a JavaScript wrapper like instantiate. A compile that is pending in a request settles one event loop turn after V8's promise instead of whenever something else pumped the message loop. We accept both. wasm-compile-test covers what a Worker sees, including a compile and a streaming body left pending when their request ends, and hangs without this. wasm-dynamic-compile-test covers what the embedder sees. The four wasm/jsapi constructor tests that were disabled for the hang now pass.
The WebAssembly Web API tests cover compileStreaming() and instantiateStreaming(): the Response checks, bodies, aborts, invalid code, imports and the IDL. In this patch wasm/webapi runs with webassembly_streaming and webassembly_dynamic_compilation, and with fetch_invalid_response_type_error so that Response.error() is the network error the tests expect. 281 of 283 subtests pass. The two CORS tests fail because the harness has no second-port origin. historical.any.js uses indexedDB, so it is omitted, and the esm-integration tests are browser-only.
0f5cb4d to
882d1a0
Compare
There was a problem hiding this comment.
✅ Approved — The only change since the last approved review is two correct CPP_SHIMS build entries; no new findings.
The decision is advisory: this review is a comment and never approves, blocks or requests changes on the pull request.
✅ All checks passed
🔒 Security: ✅ LGTM
The change since the last review only touches the build graph. Both new flags are experimental and off by default. Whether dynamic compilation should ship separately is a product decision for the maintainers.
📖 AGENTS.md: ✅ LGTM
No issues found.
📋 Code Quality: ✅ LGTM
The new CPP_SHIMS entries for //src/workerd/api/wasm-api:ffi.c++ and :ffi.h follow the same pattern as the existing io-context and entrypoint entries, and src/workerd/api/wasm-api/BUILD.bazel exports both files. The shims don't use C++ JSG (JSG_TRY, jsg::Lock::from, jsg::check or createTunneledException).
⚡ Performance: ✅ LGTM
No runtime cost in the change since the last review.
📝 Documentation: ✅ LGTM
No issues found.
Reviewed commit: 882d1a00
WebAssembly.compile()andinstantiate()with bytes could hang a request. V8 compiles off the main thread and settles the promise from a foreground task, but posting a task doesn't wake the KJ event loop, so nothing ran it until some other event came along, and then outside the request. Workers also had noWebAssembly.compileStreaming()orinstantiateStreaming(), which V8 provides only when the embedder sets a streaming callback, and couldn't compile a module they fetch while handling a request.In this patch:
ForegroundTaskSignalwhenever V8 posts a foreground task. A post takes no lock while nothing waits.wasm-api, adds the rest. The shim calls V8's compile functions through a RustcompileWasm(), and while V8's promise is pending in a request, the request runs V8's foreground tasks inside itself whenever V8 posts one, so the Worker gets the result in the request. Compiles at startup, instantiating a compiled Module, and promises V8 already settled pass through.webassembly_streamingflag, the shim checks the Response as the WebAssembly Web API specifies and reads its body into a Rust sink that feeds V8's streaming compiler.webassembly_dynamic_compilationflag, a Worker may compile WebAssembly while handling a request.eval()stays disallowed, and each module's bytes go toIoChannelFactory::submitWasmModule()first, which can refuse it. The shim wrapsWebAssembly.ModulelikeInstance, so a call withoutnewthrows before V8 sees the bytes.new WebAssembly.Module()can't wait, so if the embedder refuses its module later, the request is aborted and the isolate condemned. The default accepts every module.Workers that compile asynchronously today, at startup or under unsafe eval, see
WebAssembly.compileandWebAssembly.Modulebecome JavaScript wrappers likeinstantiateandInstance, and a compile pending in a request settles one event loop turn after V8's promise. We accept both.wasm-compile-testhangs without the fix. The four disabled wasm/jsapi constructor tests now pass, and the new wasm/webapi WPT suite passes 281 of 283; the two CORS tests need a second-port origin the harness doesn't have.Fixes #7930.