{"record":{"id":"f96dba1d82603cff","repo":"denoland/deno","slug":"couldn-t-consume-wasmstreamingresource-f96dba","errorCode":null,"errorMessage":"Couldn't consume WasmStreamingResource.","messagePattern":"Couldn't consume WasmStreamingResource\\.","errorType":"panic","errorClass":null,"httpStatus":null,"severity":"error","filePath":"libs/core/ops_builtin_v8.rs","lineNumber":1464,"sourceCode":"  state: Rc<RefCell<OpState>>,\n  rid: u32,\n  error: v8::Local<v8::Value>,\n) -> Result<(), ResourceError> {\n  // NOTE: v8::WasmStreaming::abort can't be called while `state` is borrowed;\n  let wasm_streaming = state\n    .borrow_mut()\n    .resource_table\n    .take::<WasmStreamingResource>(rid)?;\n\n  // At this point there are no clones of Rc<WasmStreamingResource> on the\n  // resource table, and no one should own a reference because we're never\n  // cloning them. So we can be sure `wasm_streaming` is the only reference.\n  match std::rc::Rc::try_unwrap(wasm_streaming) {\n    Ok(wsr) => {\n      wsr.0.into_inner().abort(Some(error));\n    }\n    _ => {\n      panic!(\"Couldn't consume WasmStreamingResource.\");\n    }\n  }\n  Ok(())\n}\n\n// This op calls `op_apply_source_map` re-entrantly.\n#[op2(reentrant)]\npub fn op_destructure_error<'s, 'i>(\n  scope: &mut v8::PinScope<'s, 'i>,\n  error: v8::Local<'s, v8::Value>,\n) -> JsError {\n  *JsError::from_v8_exception(scope, error)\n}\n\n/// Effectively throw an uncatchable error. This will terminate runtime\n/// execution before any more JS code can run, except in the REPL where it\n/// should just output the error to the console.\n#[op2(fast, reentrant)]","sourceCodeStart":1446,"sourceCodeEnd":1482,"githubUrl":"https://github.com/denoland/deno/blob/336da420f4343cbb1dcbd5eed9d075ff555ed6ee/libs/core/ops_builtin_v8.rs#L1446-L1482","documentation":"The abort path of Deno's wasm streaming: when a compilation is aborted, the op takes the WasmStreamingResource out of the resource table and must be its sole owner (Rc::try_unwrap) to call abort() on the underlying stream. If another Rc reference survives, the unwrap fails and the process panics. This is an internal lifecycle invariant; the documented API surface never exposes those references.","triggerScenarios":"A WebAssembly.compileStreaming promise being aborted or rejected while an extra reference to the streaming resource is alive — resource-table misuse by tooling, or a race between abort and completion inside deno_core. The sibling close() path in ops_builtin.rs has the identical guard.","commonSituations":"Custom tooling that holds or closes wasm resource ids during an in-flight compilation; races between abort and completion on older deno_core versions; practically unseen in normal CLI usage.","solutions":["Update Deno/deno_core — lifecycle races in the streaming resource are fixed at the core level","Do not touch resource ids for in-flight wasm compilations; let the promise settle","Reproduce minimally (compileStreaming plus a concurrent abort) and report to denoland/deno with the script"],"exampleFix":"// before — aborting while manually manipulating the resource id\nconst p = WebAssembly.compileStreaming(fetch(\"./mod.wasm\"));\nDeno.core.close(wasmRid); // during in-flight compilation\n\n// after — only abort via the promise; never touch the rid\nconst p = WebAssembly.compileStreaming(fetch(\"./mod.wasm\")).catch((e) => {\n  console.error(\"compile aborted:\", e);\n  return null;\n});","handlingStrategy":"validation","validationCode":"// let abort flow through the promise; never touch the streaming rid\nconst mod = await WebAssembly.compileStreaming(fetch(\"./mod.wasm\")).catch((e) => {\n  console.error(\"compile aborted:\", e);\n  return null;\n});","typeGuard":null,"tryCatchPattern":null,"preventionTips":["Abort wasm compilations by dropping/rejecting the promise, never by manipulating resource ids","Await or settle all streaming compilations before teardown/cleanup code runs","Report races between abort and completion with a minimal script — they are core-level fixes"],"tags":["wasm","deno-core","resources","abort","streaming-compiler"],"backgroundTag":"wasm-streaming-resource-misuse","analyzedSha":"336da420f4343cbb1dcbd5eed9d075ff555ed6ee","analyzedAt":"2026-08-20T13:07:44.778Z","contentChangedAt":"2026-08-20T13:07:44.778Z","schemaVersion":2},"datasetVersion":"2026-09-14T00:17:10.932Z"}