mirror of
https://github.com/nodejs/node.git
synced 2026-11-26 21:58:26 -05:00
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:
1 parent
39e0c14455
commit
570952d4f3
1 file changed
+4
-1
Vendored
+4
-1
@@ -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)
|
||||
})
|
||||
Reference in new issue
Block a user