mirror of
https://github.com/tinygo-org/tinygo.git
synced 2026-08-05 11:37:46 +00:00
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.
This commit is contained in:
@@ -305,8 +305,7 @@
|
||||
"syscall/js.finalizeRef": (v_ref) => {
|
||||
// Note: TinyGo does not support finalizers so this is only called
|
||||
// for one specific case, by js.go:jsString. and can/might leak memory.
|
||||
const id = mem().getUint32(unboxValue(v_ref), true);
|
||||
// Note that this if is so far seemingly never true. Someone should investigate why.
|
||||
const id = v_ref & 0xffffffffn;
|
||||
if (this._goRefCounts?.[id] !== undefined) {
|
||||
this._goRefCounts[id]--;
|
||||
if (this._goRefCounts[id] === 0) {
|
||||
@@ -316,8 +315,7 @@
|
||||
this._idPool.push(id);
|
||||
}
|
||||
} else {
|
||||
// Log as a hint and reminder that something is probably off.
|
||||
console.log("syscall/js.finalizeRef: unknown id", id);
|
||||
console.error("syscall/js.finalizeRef: unknown id", id);
|
||||
}
|
||||
},
|
||||
|
||||
|
||||
Reference in New Issue
Block a user