Skip to content

test(spawn): select the stdout socket in stale-fd fixture - #45023

Open
steipete wants to merge 1 commit into
oven-sh:mainfrom
steipete:upstream/test-stdout-socket-selection
Open

steipete wants to merge 1 commit into
oven-sh:mainfrom
steipete:upstream/test-stdout-socket-selection

Conversation

@steipete

Copy link
Copy Markdown
Collaborator

What does this PR do?

Make the stale-pipe-fd regression select the stdout socket rather than accidentally counting a newly initialized kqueue on macOS. fstat() reports a kqueue as FIFO-shaped, so the fixture's isFIFO() || isSocket() filter can find two candidates and fail before reaching FilePoll teardown.

Bun creates subprocess stdout with a socketpair on these platforms. Filter for sockets, preserving the exact-one-candidate check, fd reuse check, and stale-registration teardown assertions.

Related: #31701 and #31821. Adapted from openclaw#147.

How did you verify your code works?

On upstream main 7c96a1212, a source-extracted fixture with a real kqueue opened between its descriptor snapshots fails before the patch with expected exactly one new pipe fd; after the patch it prints OK and exits 0. The probe verifies the extra descriptor reports isFIFO() === true and isSocket() === false. This models lazy event-loop initialization without changing the runtime.

The uninstrumented regression passes on the same upstream canary and on a fresh debug build of main: 1 test, 3 assertions.

bun bd test test/js/bun/spawn/spawn-pipe-stale-fd-unregister.test.ts

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

Claude Code Review

This pull request is from a fork — automated review is disabled. A repository maintainer can comment @claude review to run a one-time review.

@coderabbitai

coderabbitai Bot commented Oct 12, 2026 •

Copy link
Copy Markdown
Contributor

Review in Change Stack →

No actionable comments were generated in the recent review. 🎉

ℹ️ Recent review info
⚙️ Run configuration
  • Configuration used: Repository: oven-sh/bun/.coderabbit.yaml
  • Review profile: ASSERTIVE
  • Plan: Advanced
  • Run ID: 3b253a19-c315-45e7-9aff-124c5637f710

📥 Commits

Reviewing files that changed from the base of the PR and between 39bbb71 and cc902b9.


📒 Files selected for processing (1)
  • test/js/bun/spawn/spawn-pipe-stale-fd-unregister.test.ts

Included review availability: This review used your included allowance. Your plan provides up to 10 included reviews per hour; 5 remain after this review.



Walkthrough

The test fixture now scans socket descriptors, excludes FIFO descriptors from its snapshots, and reports an error if it does not find exactly one new socket descriptor.

Changes

Socket descriptor test

Layer / File(s) Summary
Socket scan and assertion
test/js/bun/spawn/spawn-pipe-stale-fd-unregister.test.ts
The fixture records only socket descriptors in its baseline and candidate snapshots. Its assertion message identifies the expected descriptor as a socket.

Priority: ⬇️ Low

Merge Risk: ⚪ Minimal · up to cc902

This change only narrows descriptor discovery in the regression test; its key assertions remain intact, and no actionable merge risk is evident.

Architecture Summary

Architecture risk: 🔵 Low · up to cc902

The change affects 1 system.

Changed systems: test

Architecture concerns
No architecture-level concerns identified.

Review details

Systems and components

  • observed — test (service) was modified; 1 changed file maps to changed impact.

Before / after behavior

  • observed — Modified behavior in test/js/bun/spawn/spawn-pipe-stale-fd-unregister.test.ts: The fixture replaces pipeFds with socketFds, retaining descriptor enumeration and fstat error handling but recording only sockets; FIFO descriptors are no longer candidates. The baseline snapshot now uses the socket-only scan.
  • observed — Modified behavior in test/js/bun/spawn/spawn-pipe-stale-fd-unregister.test.ts: Candidate discovery now compares socket-only snapshots instead of snapshots containing FIFOs and sockets. The assertion still requires exactly one new descriptor, but its comment and error message now describe a socket rather than a pipe.

Pre-merge checks | Passed 4
✅ Passed checks (4 passed)
Check name Status Explanation
Title check Passed The title clearly and concisely describes the main change: selecting the stdout socket in the stale-file-descriptor fixture.
Description check Passed The description completes both required sections. It explains the bug, the implementation, related issues, and verification results with the test command and observed outcomes.
Linked Issues check Passed Check skipped because no linked issues were found for this pull request.
Out of Scope Changes check Passed Check skipped because no linked issues were found for this pull request.

  • Autofix · Keep fixing CodeRabbit findings and required CI, and resolving merge conflicts

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

✨ Finishing Touches 💡 1
🛠️ Fix failing CI checks 💡
  • Commit to this branch
  • Create a new PR

This branch has not been deployed

No deployments
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

1 participant