Skip to content

WeakMap entries with tuple keys might get lost after GC #3

@0f-0b

Description

@0f-0b

Run the code below with node --expose-gc. One might expect the output to be value, but it actually prints undefined.

import { Tuple } from "libtuple";
import { setTimeout } from "node:timers/promises";

const data = new WeakMap();
data.set(Tuple("key"), "value");
await setTimeout();
gc();
console.log(data.get(Tuple("key")));

I think this should be documented under the “Limitations” section of the readme, because I don't see a way to fix this without causing memory leaks.

Metadata

Metadata

Assignees

Labels

No labels
No labels

Projects

No projects

Milestone

No milestone

Relationships

None yet

Development

No branches or pull requests

Issue actions