Skip to content

Commit 150d9d1

Browse files
committed
fix: correctly handle id lookup for finalizeRef call
Modify the ID used for looking up the reference, based on suggestion made by @prochac Also use console.error in the caase that the reference is not found, since it is now actually known to be an error.
1 parent 8fe0391 commit 150d9d1

File tree

1 file changed

+2
-4
lines changed

1 file changed

+2
-4
lines changed

targets/wasm_exec.js

+2-4
Original file line numberDiff line numberDiff line change
@@ -305,8 +305,7 @@
305305
"syscall/js.finalizeRef": (v_ref) => {
306306
// Note: TinyGo does not support finalizers so this is only called
307307
// for one specific case, by js.go:jsString. and can/might leak memory.
308-
const id = mem().getUint32(unboxValue(v_ref), true);
309-
// Note that this if is so far seemingly never true. Someone should investigate why.
308+
const id = v_ref & 0xffffffffn;
310309
if (this._goRefCounts?.[id] !== undefined) {
311310
this._goRefCounts[id]--;
312311
if (this._goRefCounts[id] === 0) {
@@ -316,8 +315,7 @@
316315
this._idPool.push(id);
317316
}
318317
} else {
319-
// Log as a hint and reminder that something is probably off.
320-
console.log("syscall/js.finalizeRef: unknown id", id);
318+
console.error("syscall/js.finalizeRef: unknown id", id);
321319
}
322320
},
323321

0 commit comments

Comments
 (0)