From cd47e0399ea8cc5e0f89e0980640ecd0c7d1a233 Mon Sep 17 00:00:00 2001 From: Patricio Whittingslow Date: Thu, 27 Aug 2026 14:16:29 -0300 Subject: [PATCH] targets:wasm_exec.js set _pendingEvent to null --- targets/wasm_exec.js | 8 ++++++++ 1 file changed, 8 insertions(+) diff --git a/targets/wasm_exec.js b/targets/wasm_exec.js index 1cab8e5487..2689692dd4 100644 --- a/targets/wasm_exec.js +++ b/targets/wasm_exec.js @@ -490,6 +490,14 @@ this._idPool = []; // unused ids that have been garbage collected this.exited = false; // whether the Go program has exited this.exitCode = 0; + // syscall/js.handleEvent reads _pendingEvent and returns early only when + // it IsNull(). Leaving it `undefined` is not null, so handleEvent falls + // through to cb.Get("id") and panics with "call of Value.Get on + // undefined", which surfaces as RuntimeError: unreachable. Upstream Go's + // wasm_exec.js initializes this in its constructor; this line restores + // parity. Any resume() that runs without a pending event -- and resume() + // always spawns a handleEvent goroutine -- depends on it. + this._pendingEvent = null; // event awaiting dispatch by syscall/js.handleEvent if (this._inst.exports._start) { let exitPromise = new Promise((resolve, reject) => {