From 075fb10db9bd88165e4ba432261db696e35c06a6 Mon Sep 17 00:00:00 2001 From: robobun <117481402+robobun@users.noreply.github.com> Date: Wed, 15 Jul 2026 21:59:38 +0000 Subject: [PATCH] test: close the /proc FileHandle in test-fs-promises-file-handle-readFile Syncs validateReadFileProc() with upstream nodejs/node@2eeb65fa81. Since #33693, a FileHandle collected without close() throws ERR_INVALID_STATE from a FinalizationRegistry. This test opened /proc/sys/kernel/hostname and never closed it, so whenever GC fired during the later doReadAndCancel() section the process crashed with 'A FileHandle object was closed during garbage collection'. It has been flaking on ~35% of Linux CI builds (140/400 sampled). --- .../node/test/parallel/test-fs-promises-file-handle-readFile.js | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/test/js/node/test/parallel/test-fs-promises-file-handle-readFile.js b/test/js/node/test/parallel/test-fs-promises-file-handle-readFile.js index b7c9998dca09..8f266c7e357f 100644 --- a/test/js/node/test/parallel/test-fs-promises-file-handle-readFile.js +++ b/test/js/node/test/parallel/test-fs-promises-file-handle-readFile.js @@ -46,7 +46,7 @@ async function validateReadFileProc() { if (!common.isLinux) return; - const fileHandle = await open('/proc/sys/kernel/hostname', 'r'); + await using fileHandle = await open('/proc/sys/kernel/hostname', 'r'); const hostname = await fileHandle.readFile(); assert.ok(hostname.length > 0); }