Skip to content

Commit c612f35

Browse files
authored
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 PR-URL: #64085 Refs: https://github.com/nodejs/reliability/issues?q=%22test-process-finalization%22 Reviewed-By: Luigi Pinca <luigipinca@gmail.com> Reviewed-By: Gürgün Dayıoğlu <hey@gurgun.day> Reviewed-By: Stefan Stojanovic <stefan.stojanovic@janeasystems.com>
1 parent c5635b8 commit c612f35

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)