Skip to content

Commit 684a78a

Browse files
committed
test: keep finalization close fixture ref alive
The close fixture expects the registered object to still be reachable when the process emits exit. Keep a strong reference outside setup() so the assertion does not depend on platform-specific GC timing. Signed-off-by: Kamat, Trivikram <16024985+trivikr@users.noreply.github.com> Assisted-by: openai:gpt-5.5
1 parent 1434a07 commit 684a78a

1 file changed

Lines changed: 4 additions & 1 deletion

File tree

test/fixtures/process/close.mjs

Lines changed: 4 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,7 +1,9 @@
11
import { strictEqual } from 'assert'
22

3+
let obj
4+
35
function setup() {
4-
const obj = { foo: 'bar' }
6+
obj = { foo: 'bar' }
57
process.finalization.register(obj, shutdown)
68
}
79

@@ -14,5 +16,6 @@ function shutdown(obj) {
1416
setup()
1517

1618
process.on('exit', function () {
19+
strictEqual(obj.foo, 'bar')
1720
strictEqual(shutdownCalled, true)
1821
})

0 commit comments

Comments
 (0)