Skip to content

test: deflake test-worker-message-port-transfer-filehandle-fd0 - #66980

Open
christianaurichzm wants to merge 1 commit into
nodejs:mainfrom
christianaurichzm:deflake-filehandle-fd0
Open

christianaurichzm wants to merge 1 commit into
nodejs:mainfrom
christianaurichzm:deflake-filehandle-fd0

Conversation

@christianaurichzm

Copy link
Copy Markdown
Contributor

test-worker-message-port-transfer-filehandle-fd0 closes stdin in a child and expects the next open() to return fd 0. That only holds if no other thread opens a descriptor in between, which Node.js does not guarantee: V8's GC threads, for example, read /sys/devices/system/cpu/online the first time they contend on a lock. On ubuntu2404_sharedlibs_withoutssl_x64 the test failed twice with 17 !== 0, and test-filehandle-close recently hit the same kind of fd reuse there (#66750).

The parent now passes the test file as the child's stdin, and the child wraps fd 0 in a FileHandle, so the descriptor is open from the start. After the transfer is discarded, the test accepts an fd 0 that was reused for another file.

I could not reproduce the CI failure without forcing the race. With a preload that keeps a worker opening and closing /dev/zero, the test fails 120/200 on main and 0/500 with this change, and it still fails 20/20 if ~TransferData() skips fd 0 again.

Refs: nodejs/reliability#1701
Refs: #66750

The child closed stdin and expected the next open() to return fd 0,
but another thread can open a descriptor in between and take it.

Pass the file to the child as stdin and wrap fd 0 in a FileHandle, so
it is open from the start. After the transfer is discarded, accept an
fd 0 that was reused for another file.

Signed-off-by: Christian Aurich Zanettini Martins <christian.aurichzm@gmail.com>
@nodejs-github-bot nodejs-github-bot added needs-ci PRs that need a full CI run. test Issues and PRs related to Node.js core tests and test infrastructure. labels Oct 24, 2026
@codecov

codecov Bot commented Oct 24, 2026 •

Copy link
Copy Markdown

Codecov Report

✅ All modified and coverable lines are covered by tests.
✅ Project coverage is 90.60%. Comparing base (1eb734d) to head (56a1b32).
⚠️ Report is 10 commits behind head on main.

Additional details and impacted files
@@            Coverage Diff             @@
##             main   #66980      +/-   ##
==========================================
+ Coverage   90.58%   90.60%   +0.02%     
==========================================
  Files         797      797              
  Lines      278298   278298              
  Branches    53523    53513      -10     
==========================================
+ Hits       252095   252154      +59     
+ Misses      16570    16519      -51     
+ Partials     9633     9625       -8     

see 33 files with indirect coverage changes

🚀 New features to boost your workflow:
  • ❄️ Test Analytics: Detect flaky tests, report on failures, and find test suite problems.
  • 📦 JS Bundle Analysis: Save yourself from yourself by tracking and limiting bundle sizes in JS merges.

@christianaurichzm

Copy link
Copy Markdown
Contributor Author

@panva Could you take a look at this PR when you get a chance? Same kind of fd reuse as #66750. Thanks!

@panva panva added author ready PRs with CI started, the required approvals, and no outstanding review comments. request-ci Add this label to start a Jenkins CI on a PR. Only starts once the PR has an approving review. flaky-test Issues and PRs involving tests that fail intermittently in CI. labels Oct 25, 2026
@github-actions github-actions Bot removed the request-ci Add this label to start a Jenkins CI on a PR. Only starts once the PR has an approving review. label Oct 25, 2026
@nodejs-github-bot

Copy link
Copy Markdown
Collaborator

@panva panva added the commit-queue PRs queued for automated landing through the Commit Queue. label Oct 25, 2026
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

author ready PRs with CI started, the required approvals, and no outstanding review comments. commit-queue PRs queued for automated landing through the Commit Queue. flaky-test Issues and PRs involving tests that fail intermittently in CI. needs-ci PRs that need a full CI run. test Issues and PRs related to Node.js core tests and test infrastructure.

Projects

None yet

Development

Successfully merging this pull request may close these issues.

3 participants