Skip to content

test: close the /proc FileHandle in test-fs-promises-file-handle-readFile - #34283

Merged
dylan-conway merged 1 commit into
mainfrom
claude/farm/f12ca5a0/fs-handle-readfile-proc-close
Jul 24, 2026
Merged

test: close the /proc FileHandle in test-fs-promises-file-handle-readFile#34283
dylan-conway merged 1 commit into
mainfrom
claude/farm/f12ca5a0/fs-handle-readfile-proc-close

Conversation

@robobun

@robobun robobun commented Jul 15, 2026

Copy link
Copy Markdown
Collaborator

What

Sync validateReadFileProc() with upstream nodejs/node@2eeb65fa81 (const to await using) so the /proc/sys/kernel/hostname FileHandle is disposed.

Why

#33693 added a FinalizationRegistry that throws ERR_INVALID_STATE when a FileHandle is collected without close() (DEP0137 end-of-life). This test opened the hostname fd and never closed it; whenever GC happened to run during the later doReadAndCancel() section, the registry fired and the process exited 1 with:

error: A FileHandle object was closed during garbage collection. This used to be allowed with a deprecation warning but is now considered an error. Please close FileHandle objects explicitly. File descriptor: 9 (/proc/sys/kernel/hostname)
 code: "ERR_INVALID_STATE"
      at onFileHandleCollected (node:fs/promises:119:78)

It has been in the flaky annotation on 140 of the last 400 Buildkite builds (Linux lanes only, heaviest on x64-asan where GC pressure is highest).

#33693 already fixed three other vendored tests the same way; this one was missed because it is Linux-only and GC-timing-dependent. Upstream Node made the same change in nodejs/node@2eeb65fa81.

Verification

$ bun bd test/js/node/test/parallel/test-fs-promises-file-handle-readFile.js
# exit 0

The failure is GC-timing-dependent so a deterministic fail-before is not available locally; the evidence is the CI annotation count plus the fact that the unclosed handle is the only one in the file whose path matches the error's (/proc/sys/kernel/hostname).


no test proof · iteration 0 · docs-only change; test-proof not applicable

…File

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).
@coderabbitai

coderabbitai Bot commented Jul 15, 2026

Copy link
Copy Markdown
Contributor

Warning

Review limit reached

@robobun, you've reached your PR review limit, so we couldn't start this review.

Next review available in: 2 minutes

Enable usage-based reviews in Billing to review now. Otherwise, wait until the next included review is available.
You're only billed for reviews past your plan's rate limits ($0.25/file).

How can I continue?

After more reviews become available, a review can be triggered using the @coderabbitai review command as a PR comment. Alternatively, push new commits to this PR.

To avoid repeated limits, reduce automatic review volume by pausing incremental auto-reviews earlier, using label-based review opt-in, excluding WIP or generated PR titles, or requesting reviews manually when the PR is ready. If your team needs uninterrupted high-volume reviews, an organization admin can enable usage-based reviews.

How do review limits work?

CodeRabbit enforces per-developer PR review limits for each organization. Most developers receive the normal plan review availability.

For paid Pro and Pro+ PR reviews, CodeRabbit uses adaptive limits for sustained high-volume activity. When a developer's recent PR review activity reaches the 95th percentile or higher among CodeRabbit users, additional reviews become available more gradually as earlier reviews age out of the rolling window.

Please refer docs for additional details.

Review details
⚙️ Run configuration

Configuration used: Path: .coderabbit.yaml

Review profile: ASSERTIVE

Plan: Pro

Run ID: 3fbe5af0-deeb-4f00-b0a3-18bc326fa4dd

📥 Commits

Reviewing files that changed from the base of the PR and between 5d350cc and 075fb10.

📒 Files selected for processing (1)
  • test/js/node/test/parallel/test-fs-promises-file-handle-readFile.js

Comment @coderabbitai help to get the list of available commands.

@robobun

robobun commented Jul 15, 2026

Copy link
Copy Markdown
Collaborator Author
Updated 6:52 PM PT - Jul 15th, 2026

@robobun, your commit 075fb10 has 2 failures in Build #73457 (All Failures):


🧪   To try this PR locally:

bunx bun-pr 34283

That installs a local version of the PR into your bun-34283 executable, so you can run:

bun-34283 --bun

@claude claude Bot left a comment

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

LGTM — one-line test-only sync with upstream Node to close a leaked FileHandle.

What was reviewed:

  • Confirmed FileHandle implements [Symbol.asyncDispose]close() in src/js/node/fs.promises.ts:726, so await using disposes correctly.
  • Verified this was the only unclosed open() in the file; the other handles already have explicit close() / try-finally.
  • Change matches upstream nodejs/node@2eeb65fa81 and the pattern applied to sibling tests in #33693.
Extended reasoning...

Overview

Single-line change in a vendored Node.js parallel test: const fileHandle = await open(...)await using fileHandle = await open(...) in validateReadFileProc(). This ensures the /proc/sys/kernel/hostname FileHandle is closed when the function returns, instead of being leaked and later triggering the DEP0137 end-of-life ERR_INVALID_STATE from the FinalizationRegistry added in #33693.

Security risks

None. Test-only change; no production code paths, no new inputs, no external I/O beyond what the test already did.

Level of scrutiny

Low. This is a mechanical de-flake of a vendored upstream test, mirroring the exact fix Node.js itself made (nodejs/node@2eeb65fa81). I verified in src/js/node/fs.promises.ts that Bun's FileHandle defines [Symbol.asyncDispose] delegating to close(), so await using behaves as intended. I also scanned the rest of the test file: every other await open(...) is paired with an explicit await fileHandle.close() (one inside try/finally), so this was the only remaining leak — consistent with the CI error message naming /proc/sys/kernel/hostname.

Other factors

The PR description documents 140/400 flaky annotations on Linux lanes and explains why a deterministic local repro isn't available (GC-timing-dependent, Linux-only). No outstanding reviewer comments; no prior reviews from me. The change is self-contained, follows an established pattern already applied to three sibling tests in #33693, and cannot affect anything outside this single test file.

@robobun

robobun commented Jul 15, 2026

Copy link
Copy Markdown
Collaborator Author

CI red on build 73457 is the two most frequent hard-red flakes in the pipeline right now, neither related to this diff:

This diff touches only test-fs-promises-file-handle-readFile.js, which passed on every lane. Ready for review.

@dylan-conway
dylan-conway merged commit 992d6c7 into main Jul 24, 2026
78 of 79 checks passed
@dylan-conway
dylan-conway deleted the claude/farm/f12ca5a0/fs-handle-readfile-proc-close branch July 24, 2026 02:47
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

Projects

None yet

Development

Successfully merging this pull request may close these issues.

2 participants