core tests: orphan PTY slave fd test fails on Macs where /dev/ttys001 exists
Maintainers usually reply within 1 day
Nobody has claimed this yet.
Assessment
- Difficulty
- 2/5
- Estimated time
- 1-3 hours
- Newbie friendliness
- 76/100
- Issue type
- Bug
- Clarity
- Clearly specified
- Activity status
- Active
- Tech stack
- node.js, typescript
Research direction
Read packages/core/src/services/shellExecutionService.test.ts, especially the “Orphan PTY slave FD cleanup” tests around line 1559, and inspect how closeOrphanSlaveFd uses filesystem mocks. Run npx vitest run src/services/shellExecutionService.test.ts -t "Orphan PTY slave FD cleanup" from packages/core. Done means the matching and nonmatching real path cases are mocked deliberately and the test passes independently of devices present on the machine.
Written by the indexing model from the issue text.
Description
What happened?
ShellExecutionService > Orphan PTY slave FD cleanup > synchronously closes the matching slave fd when platform is darwin in packages/core/src/services/shellExecutionService.test.ts fails on a Mac that has a second terminal tab open:
AssertionError: expected undefined to be 12
❯ src/services/shellExecutionService.test.ts:1559:22
const result = closeOrphanSlaveFd(10, '/dev/ttys001');
expect(result).toBe(12);
The test mocks fs.statSync and fs.fstatSync, but not fs.realpathSync. closeOrphanSlaveFd calls the real fs.realpathSync('/dev/ttys001'):
- On CI (Linux), or a Mac with only one terminal,
/dev/ttys001doesn't exist. The call throws,targetRealPathstaysundefined, and the function matches on the mockedrdevalone, so the test passes. - On a Mac with more than one terminal open,
/dev/ttys001is a real device.targetRealPathgets set, and the function then compares it with the realrealpathSync('/dev/fd/12'). fd 12 in the test process isn't that terminal, so the candidate is skipped and the function returnsundefined.
So the result depends on which terminals happen to be open on the machine running the tests.
To reproduce, on macOS with at least two terminal windows or tabs open:
ls -l /dev/ttys001 # exists
cd packages/core
npx vitest run src/services/shellExecutionService.test.ts -t "Orphan PTY slave FD cleanup"
# × synchronously closes the matching slave fd when platform is darwin
Changing only the path in that test to one that doesn't exist (/dev/ttys999) makes it pass, which confirms it's the real realpathSync call.
What did you expect to happen?
The test should give the same result on every machine. Mocking realpathSync alongside statSync / fstatSync (or using a device name that can't exist) would make it deterministic. Mocking it also lets the test cover the path-verification branch on purpose instead of by accident: one case where the candidate's /dev/fd/N path matches, and one where it doesn't.
I have a small test-only fix ready and can open a PR if this is OK to be marked help wanted.
Client information
Running the unit tests from source, not the installed CLI, so there's no /about output.
mainatd4cb1713f- macOS 27.3, arm64
- Node.js 20.19.0 (the version CONTRIBUTING.md asks for). Same result on Node 24.5.0.
Login information
Not applicable; unit tests only.
Anything else we need to know?
The slave-FD cleanup and this test came in with #29340. The function itself looks fine; it's only the test that reaches the real filesystem.
- Dominant language
- TypeScript
- Stars
- 109k
- Forks
- 15k
- Avg merge
- 1d 1h
- Merged PRs (30d)
- 121
Getting set up
- Ships a Dockerfile or Docker Compose file
- Has a pull request template
- Read the contributing guide
First steps
- Read the whole issue, then the project's contributing guide.
- Comment on the issue to say you are picking it up — it saves two people doing the same work.
- Fork the repository and make your change on a branch.
- Open a pull request that references the issue number.
More from google-gemini/gemini-cli
-
status/need-triage
Difficulty 2/5 1-3 hours Newbie friendliness 78/100
google-gemini/gemini-cli#30383 · 1 comment ·
Maintainers usually reply within 1 day
-
gemini mcp add --include-tools/--exclude-tools does not split comma-separated lists, silently inverting tool filteringPossibly taken @anujmishra03 claimed this 2 days ago. Openstatus/need-triage
Difficulty 2/5 1-3 hours Newbie friendliness 85/100
google-gemini/gemini-cli#30330 · 3 comments ·
Maintainers usually reply within 1 day
-
Bug: core.sshCommand="" causes fatal: unable to fork on git pushPossibly taken @sakaintp claimed this 2 days ago. Openstatus/need-triage
Difficulty 2/5 1-3 hours Newbie friendliness 76/100
google-gemini/gemini-cli#30328 · 1 comment ·
Maintainers usually reply within 1 day
-
Padded function-call name is answered under the trimmed name, so the next request fails with 400 INVALID_ARGUMENTPossibly taken @arifrhm claimed this 6 days ago. Openarea/agent status/need-triage
Difficulty 2/5 1-3 hours Newbie friendliness 85/100
google-gemini/gemini-cli#30256 · 1 comment ·
Maintainers usually reply within 1 day
-
status/need-triage
Difficulty 2/5 1-3 hours Newbie friendliness 82/100
google-gemini/gemini-cli#30242 · 1 comment ·
Maintainers usually reply within 1 day
All issues in google-gemini/gemini-cli
Similar issues
-
`@angular/[email protected]` depends on vulnerable Vite 7.3.7 - GHSA-p4f5-76q4-ffq7 (Critical RCE)Openarea: @angular/build
Difficulty 2/5 1-3 hours Newbie friendliness 65/100
angular/angular-cli#34764 ·
Maintainers usually reply within 1 day
-
P2
Difficulty 1/5 Under an hour Newbie friendliness 84/100
Maintainers usually reply within 1 day
-
bug ready-for-human
Difficulty 2/5 1-3 hours Newbie friendliness 60/100
LucasSantana-Dev/Lucky#3150 ·
Maintainers usually reply within 1 day
-
enhancement good first issue priority: low size: XS
Difficulty 2/5 1-3 hours Newbie friendliness 88/100
Maintainers usually reply within 1 day
-
Difficulty 2/5 1-3 hours Newbie friendliness 78/100
vercel-labs/scriptc#3979 ·
Maintainers usually reply within 1 day