Skip to content
Draft
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
7 changes: 6 additions & 1 deletion test/fixtures/process/different-registry-per-thread.mjs
Original file line number Diff line number Diff line change
Expand Up @@ -5,6 +5,12 @@ const registeredRefs = [];
const ref = { foo: 'foo' };
registeredRefs.push(ref);

process.on('exit', () => {
// Keep `ref` strongly reachable until exit so the per-thread finalization
// callbacks are tested without depending on GC timing.
registeredRefs.length;
});

if (isMainThread) {
process.finalization.register(ref, () => {
process.stdout.write('shutdown on main thread\n');
Expand All @@ -13,7 +19,6 @@ if (isMainThread) {
const worker = new Worker(import.meta.filename);

worker.on('error', (err) => {
// Referencing `registeredRefs` here to avoid `ref` being GCed before the worker exits.
console.log(registeredRefs);
throw err;
});
Expand Down
Loading