Closed Bug 1951982 Opened 11 days ago Closed 11 days ago

FinalizationRegistry.register throws TypeError when using a Symbol as unregister token

Categories

(Core :: JavaScript: GC, defect)

Firefox 136
defect

Tracking

()

RESOLVED DUPLICATE of bug 1863140

People

(Reporter: hansischallmoser, Unassigned)

Details

User Agent: Mozilla/5.0 (Windows NT 10.0; Win64; x64; rv:136.0) Gecko/20100101 Firefox/136.0

Steps to reproduce:

I tried using a Symbol as unregister token for FinalisationRegistry

Reproduction:

const registry = new FinalizationRegistry((held) => {
  console.log(held);
});

const token = Symbol();
let value = {};

registry.register(value,"Foo",token);

value = null;

Actual results:

TypeError: Invalid unregister token passed to FinalizationRegistry.register

Expected results:

After GC "Foo" is printed to the console. (I have verified this using {} instead of Symbol() and testing with V8)

Summary: FinalisationRegistry.register throws TypeError when using a Symbol as unregister token → FinalizationRegistry.register throws TypeError when using a Symbol as unregister token
Component: Untriaged → JavaScript: GC
Product: Firefox → Core
Status: UNCONFIRMED → RESOLVED
Closed: 11 days ago
Duplicate of bug: 1863140
Resolution: --- → DUPLICATE
You need to log in before you can comment on or make changes to this bug.