Repository navigation
test(daemon): make real-socket backpressure assertion deterministic - #31520
Conversation
|
No actionable comments were generated in the recent review. 🎉 ℹ️ Recent review info
📝 Walkthrough
Priority: ⬇️ Low Merge Risk: ⚪ Minimal · up to
|
|
The real-socket test could report a missing producer pause even when daemon backpressure worked. Its per-MiB yields let completed writes release outstanding accounting, so 8 MiB of cumulative writes did not guarantee 4 MiB pending at the assertion. #31256 changed the transport but still yielded, so callbacks could release accounting; this change removes the yields and asserts pause before callbacks can run. This test-only change establishes the pending-callback condition synchronously, then keeps the real socket drain, bounded buffering, byte conservation, background shedding, typing delivery and producer resume checks. There is no app behavior change. Production code and fake-socket contracts were not changed. Review completed with a fresh correctness reviewer and independent architecture challenger. Both found no issues; no review fixes or deferred findings remain. Full path was required because #31256 addressed the same symptom within 30 days. Readiness checks, including the proportional performance, compatibility and platform passes, found no issues. Verified:
Runtime QA is skipped ( For Brennan's review: screenshots are not applicable to this test-only change. The judgment point is the bounded synchronous flood and unchanged pause assertion; the later asynchronous delivery/resume assertions remain in place. |
ELI5
The real-socket backpressure test could fail on Linux CI even when the daemon behaved correctly. Sending 8 MiB in total did not guarantee that 4 MiB was still pending: each event-loop yield let socket write callbacks release the daemon's accounting. There is no user-facing change; this improves CI reliability.
What Changed
The bounded flood now runs synchronously until the producer pauses or the existing 8 MiB ceiling is reached. Pending write callbacks cannot run before the pause assertion, so the visible producer's pause follows from the daemon's outstanding accounting rather than kernel socket capacity. The real Unix socket / Windows named-pipe fixture and subsequent asynchronous drain, byte conservation, background shedding, typing delivery, and producer resume checks remain in place. Production code and fake-socket contracts are unchanged.
Why
A paused JavaScript reader does not determine how much data the operating system can accept. Keeping write callbacks pending establishes the condition the daemon actually guarantees without increasing the flood budget, extending timeouts, mocking the socket, or changing production behavior.
Linked Issue
Tracked in STA-11548.
Visual Proof
N/A — test-only CI reliability change with no visual or interaction changes.
Testing
ORCA_BACKGROUND_LAUNCH=1 pnpm test src/main/daemon/daemon-stream-backpressure-socket.test.tsthree times on macOS through the normal test runner and tc-gate: all four cases passed each time.Review
Self-reviewed the test against daemon pending-write accounting and verified the only changed file is the real-socket test.
Agent skill upstream boundary
Notes
Author: @BrennanKB5. No production, SSH, mobile, saved-data, or protocol changes. Existing platform-specific socket fixture is preserved.
Checklist
N/Awith reasonpnpm lint,pnpm typecheck,pnpm test, andpnpm buildpass (or CI will cover; local preferred)Review path and plan
Full review path because the same pause-assertion symptom was addressed in #31256 within the last 30 days. Runtime QA is skipped (
qa=none) because only a test changes.Plan: keep the existing real-socket fixture and flood ceiling, assert producer pressure while write callbacks are still pending, then retain the asynchronous drain and delivery checks. The full review verified the regression contract with producer pause forwarding disabled in a temporary test mutation: both visible cases failed at the unchanged pause assertion under Node and Bun, then the exact original test bytes were restored. Normal runs passed all four cases under each runtime. Production and fake-socket contracts were unchanged. Final-head CI passed after merging current main.