Repository navigation
test: isolate hook fixture connections from fake timers - #26369
Conversation
|
Review and verification summary Problem: the cancellation test User-facing change: none. Only test code changed; the hook server is untouched. Fix: the helper sends Verified:
Not verified: the exact intermittent error was seen in CI, not reproduced locally. It depends on timing, and only the closed-socket cause was demonstrated. |
|
No actionable comments were generated in the recent review. 🎉 ℹ️ Recent review info⚙️ Run configuration
📒 Files selected for processing (2)
Included review availability: This review used your included allowance. Your plan provides up to 10 included reviews per hour; 5 remain after this review. 📝 WalkthroughWalkthroughThe hook-event request fixture now sends a Priority: ⬇️ Low Merge Risk: ⚪ Minimal · up to This test-focused change addresses hook-request connection reuse and adds a regression check. No concrete merge-blocking risk is established by the available evidence. 🚥 Pre-merge checks | ✅ 4 | ❌ 1❌ Failed checks (1 warning)
✅ Passed checks (4 passed)
✨ Finishing Touches 💡 1📝 Generate docstrings 💡
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. Comment |
ELI5
The Claude cancellation test
keeps cancellation bounded unless a new prompt opens a turn: truefailed on Linux in unit shard 1 of the job labeled Node 24 with “The socket connection was closed unexpectedly.” The test file actually ran under Bun. Advancing fake time by 120 seconds expired a real HTTP connection that the test client could still try to reuse for its next Stop-hook request.There is no user-facing change: this fixes test transport only. Orca's hook handling and agent status behavior stay the same.
What Changed
The shared hook POST fixture now sends
Connection: close, matching the existing relay test transport. Every request uses a fresh connection, so fake-time advances cannot leave a stale pooled connection for the next hook. A regression test counts actual server sockets across a 120-second fake-time advance.This also covers the sibling cancellation and notification-expiry tests that use the same fixture, without changing their assertions or timers.
Why
The tests need fake timers to exercise missing-notification expiry. Keeping those timers and removing connection reuse fixes the race while preserving that coverage. Changing production timeouts, adding retries, or replacing timer advances with clock-only changes would either change application behavior or weaken the tests.
Before the fix, a temporary diagnostic recorded a live HTTP socket, then its timeout and destruction during the fake-time advance. The new regression also failed against the old fixture because three POSTs used only two server sockets.
Linked Issue
No separate issue. Found in the attempt-1 unit shard of #26173: https://github.com/stablyai/orca/actions/runs/37693271510/job/113046014894
Visual Proof
N/A — tests only; no visual or interaction change.
Testing
I manually tested these changes locally
Automated tests added/updated, or explained why not below
macOS arm64: 20 sequential runs under Bun 1.4.2, launched through the same wrapper as CI with Node 24.18.0. Each run passed all 61 tests in the wake-up lifecycle, cancellation capture, notification-expiry, and fixture regression files.
The same four files passed directly under Node 24.18.0 and Node 26.5.0 (61 tests each).
The regression failed with the old helper (two sockets for three POSTs) and passed with the fix (three sockets).
tc-gate pnpm tc:nodepassed.orca-ci-checks --no-typecheckpassed all checks immediately after the Node typecheck; the changed-code quality check also passed with the new test staged.Changed-file lint, formatting, and
git diff --checkpassed.The diagnostic proves fake time destroys the pooled socket; the exact intermittent fetch exception was observed in CI, not reproduced locally. Linux verification is provided by PR CI. No Electron app was launched.
Review
Self-reviewed the test helper, hook listener, timer implementation, sibling tests, and regression. Production files are unchanged.
Agent skill upstream boundary
Notes
Author: @BrennanKB5
Platform-independent HTTP headers only. Existing local and relay paths remain covered. No change to SSH execution, folder workspaces, remote protocol compatibility, or production behavior.
Checklist
N/Awith reasonpnpm lint,pnpm typecheck,pnpm test, andpnpm buildpass (or CI will cover; local preferred)