Repository navigation
test(daemon): run the stalled-reader backpressure test over a Unix socket, not TCP loopback - #31256
Conversation
…cket, not TCP loopback Linux autotunes TCP loopback buffers to several MiB, so the kernel absorbed most of the 8 MiB flood, write callbacks completed, and the producer never reached the 4 MiB high-water mark on some CI runners. The daemon stream runs over a Unix socket or named pipe, whose small fixed kernel buffers keep the backlog in the daemon's own accounting.
📝 Walkthrough
Priority: ⬇️ Low Merge Risk: 🟡 Moderate · up to
|
There was a problem hiding this comment.
Actionable comments posted: 1
ℹ️ Review info
⚙️ Run configuration
- Configuration used: Repository UI
- Review profile: CHILL
- Plan: Advanced
- Run ID:
0953fc3f-6518-4198-9aa9-05a603038d3b
📒 Files selected for processing: 1
src/main/daemon/daemon-stream-backpressure-socket.test.ts
Included review availability: This review used your included allowance. Your plan provides up to 10 included reviews per hour; 4 remain after this review.
|
The stalled-reader backpressure test was failing on unrelated Linux CI changes because TCP loopback buffers could absorb the capped flood before the producer paused. The test now uses the daemon's local transport: a Unix socket on macOS/Linux and a named pipe on Windows. No shipped code or user-facing behavior changes. The light-path review completed in two rounds, including one fix and a re-check by the same reviewer. Review found that a long valid Verified on final head
Readiness checks found no shipped, mobile, saved-data or version-compatibility changes. App QA is skipped because the only changed file is a test ( For Brennan's review: main-versus-branch screenshots are not applicable because no UI changes. The only judgment point is the transport and bounded temporary path; assertions are unchanged. |
ELI5
A daemon test kept failing in CI for PRs that didn't touch the daemon. The test stalls a reader and floods a socket to check that the terminal producer pauses. It used a local network (TCP) connection. On Linux, the kernel quietly buffers several megabytes on that kind of connection, so the flood disappeared into the kernel and the producer was never asked to pause. The real daemon stream uses a Unix socket (a named pipe on Windows), which buffers very little. The test now uses that.
What Changed
src/main/daemon/daemon-stream-backpressure-socket.test.ts"bounds 1024-character writes (hidden=false) and resumes" fails in PR CI (expected false to be trueat thepausedcheck), for example in run 39507563418 on a workflow-only PR. The other three cases pass.daemon-stream-backpressure.ts,daemon-stream-data-batcher.ts,session-producer-pause.ts) hasn't changed since perf(daemon): send PTY output to main as raw bytes, not NDJSON #27006 (10-09). It counts bytes as backlog until their socket write completes. Over TCP loopback, Linux autotunes the kernel buffers, so writes keep completing into the kernel and the counted backlog stays below the 4 MiB pause threshold until most of the 8 MiB flood has gone. A standalone probe on an Ubuntu 24.04 box, writing 8 MiB to a paused reader: over TCP the kernel took about 2.5 MiB, and the 4 MiB threshold was reached only after about 6.9 MiB had been written. Over a Unix socket the kernel took about 0.1 to 0.2 MiB, and the threshold was reached at about 4.2 MiB. A CI runner with somewhat larger TCP buffers never reaches the threshold within 8 MiB. On macOS, TCP loopback buffers only about 0.5 MiB, which is why the test passes locally./tmpon POSIX, or a named pipe using a unique temporary-directory basename on Windows, the same waydaemon-health.test.tsbuilds one, and removes the directory afterwards. The fixed POSIX root keeps the complete socket path below the kernel limit even with a longTMPDIR. The assertions are unchanged.Why
Making the test use the daemon's real transport removes the dependence on kernel TCP tuning, without loosening any threshold or assertion. Raising the flood size or lowering the threshold would only move the margin. Faking the socket would stop exercising real kernel backpressure, which is the point of this test.
Plan (light path), all four criteria:
Still catches the regression: with the pause threshold temporarily raised to 64 MiB, both visible-session cases fail. Reverted before committing; independently confirmed during review.
Linked Issue
N/A, main fix.
Visual Proof
N/A: test-only change, no UI.
Testing
TMPDIRand with the reviewer's 96-byteTMPDIR; temporary-root cleanup leaves no entries.346b4d7e41c9cd9c6d7d01fd3535324bba77e0d2, including static analysis, all five test shards, relay integration, selection evidence and the aggregate gate.346b4d7e41c9cd9c6d7d01fd3535324bba77e0d2, Windows low spec, Node v24.18.0, exit 0, through qa-gate ticket 938.Review
Agent skill upstream boundary
Notes
Cross-platform: Unix socket path on macOS/Linux uses a unique directory under the fixed
/tmproot to stay below the kernel byte limit; Windows keepsos.tmpdir()and uses only the unique basename for its named pipe. Direct Windows named-pipe execution passed all four cases on the final head.Checklist
N/Awith reasonpnpm lint,pnpm typecheck,pnpm test, andpnpm buildpass (or CI will cover; local preferred)