You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
{{ message }}
Repository navigation
test(cli): stop the CLI-21 check from freezing the provider it watches - #488
The CLI-21 ask test (Ctrl-C ends akou ask, its harness processes end, the call keeps recording) failed once on check (macos-latest) with "timed out after 10000 ms waiting for the harness and its child to end", then passed on rerun. akou was not leaving processes behind. The test was holding up the cleanup it was waiting for.
Cause
The test checked for the harness with Bun.spawnSync(["ps", "-ax", ...]) on every poll. The app and its harness provider run inside the test process, so each ps froze the event loop that handles the abort, fires the 2 s SIGKILL timer and reaps the harness.
Evidence, from a loaded Mac with timing logs added to a scratch copy:
The provider's abort ran within 70 ms of the Ctrl-C every time, and the harness always exited by SIGTERM (exit 143), never by the SIGKILL fallback.
One ps -ax took 10 to 46 s under that load. A separate sampler outside the test process saw the same gaps between its own ps calls, and during the wait saw a <defunct> (dead, not yet reaped) process-group leader that was a child of a bun process. That matches the harness, though the sampler did not record pids to prove it.
In one run the 10 s wait returned after 46 s: a single poll had blocked that long. The provider saw the harness exit 1 to 100 ms after the test saw it gone, every time, because reaping had been waiting on the frozen loop.
The same blocking ps in afterAll overran its 5 s default. That was the other failure the loop turned up.
Fix
The fake harness already supports FAKE_PIDFILE. It now writes its own pid there, the child's pid goes to its existing file, and the test checks both with kill(pid, 0). No ps remains. afterAll kills from those files only if the test never saw both processes end, so it can't kill a reused pid. The product is unchanged. The ask test carries [CLI-21] itself, because the trap-coverage scanner does not read the id through describe.skipIf(...)(. TRAPS.md gets the trap.
Positive control: with the provider's abort kill removed, or with it killing only the harness and not its process group, the fixed test fails at its 10 s wait.
Repeat loop (the CLI-21 tests, 60 runs, yes burners in the loop's process group)
burners
failed
ask test median
max
before
20
8 / 60
0.67 s
47.4 s
before
40
24 / 60
12.9 s
60.2 s
after
20
0 / 60
0.16 s
0.60 s
after
40
0 / 60
0.33 s
0.75 s
bun run check on the same machine: 3580 pass, 38 skip. Its one failure (TS-6, the trap had no test named after it) led to the test rename above, and the rename fixed it.
Summary by CodeRabbit
Tests
Updated terminal interruption coverage to verify that Ctrl-C exits with status 130 and terminates the harness and its child processes while call recording continues.
Improved process-exit checks to avoid blocking during cleanup.
Documentation
Documented the expected behavior when interrupting a terminal ask command.
The ask case polled `ps -ax` through Bun.spawnSync. The app and its harness
provider run in the test process, so each poll froze the event loop that
handles the abort, fires the SIGKILL timer and reaps the harness. Under load
one `ps -ax` took 10 to 46 s, so the 10 s wait failed while akou had sent
SIGTERM within 50 ms and the harness had died of it.
The fake harness now writes its own pid (FAKE_PIDFILE), and the test checks
the harness and its child with kill(pid, 0). Written down as trap CLI-21.
Reviewing files that changed from the base of the PR and between f367612 and 3dd4860.
Files selected for processing: 2
docs/TRAPS.md
tests/cli-terminal.e2e.test.ts
Included review availability: This review used your included allowance. Your plan provides up to 1 included review per hour; 0 remain after this review.
Walkthrough
The terminal test now uses PID files to check that the harness and child processes are alive before Ctrl-C and have exited afterward. The trap documents that recording must continue.
Changes: Terminal Ctrl-C process checks
Layer / File(s)
Summary
Document and check Ctrl-C process lifecycle docs/TRAPS.md, tests/cli-terminal.e2e.test.ts
The trap documents the expected process cleanup and recording behavior. The test uses PID files instead of ps, checks that the harness and child are alive before Ctrl-C, and waits for both to exit. It uses the repository fixture directly and avoids cleanup of processes already marked as ended.
No merge-blocking regression was identified in the updated process checks.
Pre-merge checks: 5
Check name
Status
Explanation
Description Check
Check skipped - CodeRabbit’s high-level summary is enabled.
Title check
The title clearly identifies the CLI-21 test fix and accurately describes the change that prevents provider monitoring from freezing the test.
Docstring Coverage
Docstring coverage is 100.00% which is sufficient. The required threshold is 80.00%. Docstring coverage is scoped to functions touched by this diff with cyclomatic complexity of at least 2. Documentat…
Linked Issues check
Check skipped because no linked issues were found for this pull request.
Out of Scope Changes check
Check skipped because no linked issues were found for this pull request.
Full details: Docstring Coverage
Explanation
Docstring coverage is 100.00% which is sufficient. The required threshold is 80.00%. Docstring coverage is scoped to functions touched by this diff with cyclomatic complexity of at least 2. Documentation-only edits and deletions within surviving functions are included; unchanged diff context and fully deleted functions are excluded. Analyzed 2 functions across 1 files. (1 skipped: 1 unsupported.)
Finishing Touches: 💡 1
📝 Generate docstrings
Commit to this branch
Create a new PR
🧪 Generate unit tests (beta)
Commit to this branch
Create a new PR
🛠️ Fix failing CI checks: 💡
Commit to this branch
Create a new PR
Autofix · Keep fixing CodeRabbit findings and required CI, and resolving merge conflicts
Warning
Some tools did not complete. Review the errors below.
Biome (2.5.15)
tests/cli-terminal.e2e.test.ts
Biome could not lint this file: configuration resulted in errors. Check the repository's Biome configuration and plugins.
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.
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
Problem
The CLI-21 ask test (Ctrl-C ends
akou ask, its harness processes end, the call keeps recording) failed once oncheck (macos-latest)with "timed out after 10000 ms waiting for the harness and its child to end", then passed on rerun. akou was not leaving processes behind. The test was holding up the cleanup it was waiting for.Cause
The test checked for the harness with
Bun.spawnSync(["ps", "-ax", ...])on every poll. The app and its harness provider run inside the test process, so eachpsfroze the event loop that handles the abort, fires the 2 s SIGKILL timer and reaps the harness.Evidence, from a loaded Mac with timing logs added to a scratch copy:
ps -axtook 10 to 46 s under that load. A separate sampler outside the test process saw the same gaps between its ownpscalls, and during the wait saw a<defunct>(dead, not yet reaped) process-group leader that was a child of a bun process. That matches the harness, though the sampler did not record pids to prove it.psinafterAlloverran its 5 s default. That was the other failure the loop turned up.Fix
The fake harness already supports
FAKE_PIDFILE. It now writes its own pid there, the child's pid goes to its existing file, and the test checks both withkill(pid, 0). Nopsremains.afterAllkills from those files only if the test never saw both processes end, so it can't kill a reused pid. The product is unchanged. The ask test carries[CLI-21]itself, because the trap-coverage scanner does not read the id throughdescribe.skipIf(...)(. TRAPS.md gets the trap.Positive control: with the provider's abort kill removed, or with it killing only the harness and not its process group, the fixed test fails at its 10 s wait.
Repeat loop (the CLI-21 tests, 60 runs,
yesburners in the loop's process group)bun run checkon the same machine: 3580 pass, 38 skip. Its one failure (TS-6, the trap had no test named after it) led to the test rename above, and the rename fixed it.Summary by CodeRabbit
askcommand.