{"record":{"id":"ae9854b666bc32df","repo":"denoland/deno","slug":"wasm-streaming-callback-invoked-before-the-js-hand","errorCode":null,"errorMessage":"wasm streaming callback invoked before the JS handler was set","messagePattern":"wasm streaming callback invoked before the JS handler was set","errorType":"panic","errorClass":null,"httpStatus":null,"severity":"error","filePath":"libs/core/ops_builtin_v8.rs","lineNumber":1422,"sourceCode":"}\n\n/// The isolate-wide [`v8::Isolate::set_wasm_streaming_callback`] handler. It\n/// dispatches to the JS handler registered through\n/// `op_set_wasm_streaming_callback`. This is installed once at isolate creation\n/// so that it survives v8 re-installing the `WebAssembly` object (and resetting\n/// the isolate-wide streaming callback) on every newly created context.\npub fn wasm_streaming_callback<'a>(\n  scope: &mut v8::PinScope<'a, '_>,\n  arg: v8::Local<'a, v8::Value>,\n  wasm_streaming: v8::WasmStreaming<false>,\n) {\n  let context_state_rc = JsRealm::state_from_scope(scope);\n  let maybe_cb_handle = context_state_rc.js_wasm_streaming_cb.borrow().clone();\n  let Some(cb_handle) = maybe_cb_handle else {\n    // The JS handler is registered while the runtime bootstraps, before any\n    // user code can trigger wasm streaming. Reaching this without a handler\n    // means deno_core was misconfigured.\n    panic!(\"wasm streaming callback invoked before the JS handler was set\");\n  };\n\n  let streaming_rid = {\n    let state = JsRuntime::state_from(scope);\n    state\n      .op_state\n      .borrow_mut()\n      .resource_table\n      .add(WasmStreamingResource(RefCell::new(wasm_streaming)))\n  };\n\n  let undefined = v8::undefined(scope);\n  let rid = serde_v8::to_v8(scope, streaming_rid).unwrap();\n  cb_handle\n    .open(scope)\n    .call(scope, undefined.into(), &[arg, rid]);\n}\n","sourceCodeStart":1404,"sourceCodeEnd":1440,"githubUrl":"https://github.com/denoland/deno/blob/336da420f4343cbb1dcbd5eed9d075ff555ed6ee/libs/core/ops_builtin_v8.rs#L1404-L1440","documentation":"deno_core installs an isolate-wide callback for WebAssembly streaming compilation, and its bootstrap JS registers the JS-side handler before any user code runs. If native wasm streaming starts before that handler exists — a context whose bootstrap was skipped or a snapshot built without it — the runtime panics immediately because there is nothing to deliver the stream to. The panic is a deliberate misconfiguration alarm: deno_core was set up wrong, user code is not at fault.","triggerScenarios":"An embedder creating a realm and triggering wasm streaming before running the bootstrap JS that sets js_wasm_streaming_cb; using a custom snapshot serialized before the handler was registered; harnesses executing scripts in fresh realms without the standard runtime init.","commonSituations":"Custom embedders with hand-rolled bootstrap ordering; stale custom snapshots after a deno_core upgrade; test setups that bypass the runtime's normal init sequence.","solutions":["Run the standard deno_core bootstrap (which sets the wasm streaming handler) before executing any user module","Rebuild custom snapshots against the current deno_core version so the handler registration is captured","Audit embedder code for realms or contexts created without the runtime's init JS","If this happens with an unmodified Deno CLI, report it — it would be a runtime packaging bug"],"exampleFix":"// before — user code runs before the handler exists\nlet runtime = JsRuntime::new(Options { ..Default::default() });\nruntime.execute_script(\"app.js\", user_code)?;\n\n// after — bootstrap first (it registers the wasm streaming handler)\nlet runtime = JsRuntime::new(Options { ..Default::default() });\nruntime.execute_script(\"deno:bootstrap\", include_str!(\"bootstrap.js\"))?;\nruntime.execute_script(\"app.js\", user_code)?;","handlingStrategy":"validation","validationCode":"// embedder: bootstrap before any user script in every realm\nruntime.execute_script(\"deno:bootstrap\", include_str!(\"bootstrap.js\"))?;\nruntime.execute_script(\"app\", user_code)?;","typeGuard":null,"tryCatchPattern":null,"preventionTips":["Always run the runtime's standard bootstrap before user code in every realm/context","Rebuild custom snapshots against the exact deno_core version in use","Bypassing the normal init sequence in test harnesses is the most common way to hit this"],"tags":["wasm","deno-core","bootstrap","embedder","snapshot"],"backgroundTag":"wasm-streaming-handler-missing","analyzedSha":"336da420f4343cbb1dcbd5eed9d075ff555ed6ee","analyzedAt":"2026-08-20T13:07:44.778Z","contentChangedAt":"2026-08-20T13:07:44.778Z","schemaVersion":2},"datasetVersion":"2026-09-14T05:17:10.506Z"}