Skip to content

fix(tests): wait for shell-agent fixture pids without inotify - #1885

Merged
devswha merged 1 commit into
mainfrom
fix/shell-agent-test-no-inotify
Oct 24, 2026
Merged

devswha merged 1 commit into
mainfrom
fix/shell-agent-test-no-inotify

Conversation

@devswha

@devswha devswha commented Oct 24, 2026

Copy link
Copy Markdown
Owner

Fixes #1882.

What failed

Three server/shell-agent.test.ts tests failed together in bun run check fast on the maintainer's PC with EMFILE: too many open files, watch '<tmp>/ovis-shell-agent-path-*/home': "hung or oversized login probe is killed and reaped…", "answers a shell SIGKILL does not end within the bound…" and "stop cancels refresh without leaking a child".

Root cause

They waited for a fixture shell's pid file with fs.watch on its directory. Every watching process needs an inotify instance, and fs.inotify.max_user_instances (128 by default) is shared by every process of the user: with many agent sessions and their watchers, 119 to 126 of 128 were in use on that PC, and the watch was refused. Before #1864 the same refusal left a pid of 0, and the test's kill(0) ended the whole unit step with no failure reported.

Fix (test only)

  • The three waits read a FIFO that the shell writes its pid into, made before the shell starts and bounded at 5 s (the bound opens the write end itself, so the pending read ends; a bound before the read opened rejects cleanly).
  • The reads after the probe has answered read the file directly (the shell writes it first thing).
  • Pids read are asserted to be > 0, so an empty file cannot pass as "not running".

Proof

  • Reproduction: with every fs.watch refused (an injected EMFILE, and the PC's own exhausted limit at the time), main fails exactly those three tests with EMFILE; this passes all 18.
  • 32 runs, 8 at a time: 0 failures.
  • bun run check fast: passed (6396 pass, 0 fail) while the PC was at 126/128 inotify instances.
  • Reviewed by omo-native-code-reviewer (approve; its three low notes applied: read the FIFOs in the shell's write order, reject cleanly on ENXIO, assert pids > 0). Test-only: no Codex review, per the lane's policy.

Part of the flaky-tests lane.

Three server/shell-agent.test.ts tests failed together in check fast with "EMFILE: too many open
files, watch": they waited for a fixture shell's pid file with fs.watch, and each watching
process needs an inotify instance, which every process of the user shares (128 by default; 119
to 125 in use on the maintainer's PC running many agents).

The three waits now read a FIFO that the shell writes its pid into, made before the shell starts
and bounded (the bound opens the write end itself, so the pending read ends); the reads after the
probe answered read the file directly. With every fs.watch refused (an injected EMFILE, and the
PC's own limit at the time), main fails exactly those three tests and this passes all 18.

Fixes #1882
@coderabbitai

coderabbitai Bot commented Oct 24, 2026

Copy link
Copy Markdown

Warning

Review limit reached

You've used all free OSS reviews for now. Wait for the free limit to reset to keep reviewing this public repository.

Next included review available in 4 minutes.

Check out review usage here.

View limit details

Limit details: You’ve used all 4 included reviews currently available.

Learn how review limits work.

Review configuration:

Run configuration
Commits

Reviewing files that changed from the base of the PR and between 54b4db3 and bce34cb.

Files selected for processing: 1
  • server/shell-agent.test.ts
  • Autofix · Keep fixing CodeRabbit findings and required CI, and resolving merge conflicts

Thanks for using CodeRabbit! It's free for OSS, and your support helps us grow. If you like it, consider giving us a shout-out.

❤️ Share

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

@devswha

devswha commented Oct 24, 2026

Copy link
Copy Markdown
Owner Author

CodeRabbit's review was rate-limited ("Review limit reached"), so no CodeRabbit review ran on this PR. The review below stands in for it.

omo-native-code-reviewer: APPROVE, no blockers. It checked deadlock freedom (each FIFO and its read exist before the shell starts), the bound (a reader blocked in open() counts as a reader, so the non-blocking write open ends it), and that the direct reads after the probe are written before it answers. Its three low notes are applied: the FIFOs are read in the order the shell writes them, a bound that fires before the read opened rejects cleanly (ENXIO), and pids are asserted > 0. Not changed: these tests are Linux-only in CI.
Test-only: no Codex review, per the lane's review policy.

@devswha

devswha commented Oct 24, 2026

Copy link
Copy Markdown
Owner Author

Merge pass review-work report. Overall: PASSED. This PR changes a test only. Under the maintainer's token rule it merges on the code review, the merge pass's own check and CI, without the gate reviewer. It is first in the queue because it unblocks every lane's local check fast.

Lane Verdict
Code review (omo-native-code-reviewer, programming + remove-ai-slops) PASS (CLEAR)
Merge pass's own check server/shell-agent.test.ts 5 runs, 18/18 each; conventions and typecheck pass; git merge-tree is clean against main and against #1863, which shares this file

What was checked

  • The 5 s bound. It opens the FIFO's write end with O_NONBLOCK, so a pending read ends even when the shell never writes. A scratch copy with a 500 ms bound failed at 503 ms and exited cleanly.
  • Bound fires before the read opens. The test still fails in time. The read starts 5 s before the timer, so this can't happen in practice.
  • No pid of 0 or an empty pid can reach kill(). Every pid is checked to be greater than 0.
  • Cleanup. The FIFO lives in the fixture home, which afterEach removes.
  • Fixed sleeps. The one setTimeout is a bounded deadline raced against the read, the same shape as the existing within helper.

Follow-ups (LOW)

  • The timer's catch swallows every error, not only ENXIO.
  • In the impossible early-bound case, a readFile can stay stuck on a background thread.

All required checks are green, and no review thread is open.

CodeRabbit did not review this PR (rate-limited or skipped). The reviews above stand in for it.

@devswha
devswha merged commit a575bd5 into main Oct 24, 2026
18 checks passed
@devswha
devswha deleted the fix/shell-agent-test-no-inotify branch October 24, 2026 14:48
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.

Flaky: shell-agent.test.ts fails with EMFILE when the PC is out of inotify instances

1 participant