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: https://github.com/nodejs/node/pull/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>
This commit is contained in:
Trivikram Kamat authored and Richard Lau committed 2026-07-03 16:04:10 +00:00
1 parent 39e0c14455
commit 570952d4f3
1 file changed
+4 -1
+4 -1
View File
@@ -1,7 +1,9 @@
import { strictEqual } from 'assert'
let obj
function setup() {
const obj = { foo: 'bar' }
obj = { foo: 'bar' }
process.finalization.register(obj, shutdown)
}
@@ -14,5 +16,6 @@ function shutdown(obj) {
setup()
process.on('exit', function () {
strictEqual(obj.foo, 'bar')
strictEqual(shutdownCalled, true)
})