Repository navigation
fix(diagnostics): end a connection report body that takes over 10 s to arrive - #1883
Conversation
…o arrive A signed-in device could hold every one of the 16 report read slots by sending each body one byte at a time, so every other report got 429 until those reads ended. Each body now has one 10 s deadline for the whole read (a timer for a body that stops arriving, a clock check after each chunk for one that keeps trickling); past it the request gets 408 trace_timeout and its slot is free again. Refs #1425
…calls Traces the tests opened stayed in the live set, so resumeConnectionTraces() in a later test also reached earlier tests' traces. Each test's traces are now closed after it. authenticate and pairDevice get tests for their request and for resuming reporting only after a successful sign-in. Refs #1425
|
Warning Review limit reachedYou'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 18 minutes. View limit details
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 |
|
CodeRabbit hit its review limit on this PR, and it changes an HTTP route's contract (a new 408), so here are the reviews that stand in for it (AGENTS.md): omo-native-code-reviewer: APPROVE, two LOW notes:
Codex (gpt-6.1-sol, xhigh reasoning): APPROVE, no findings. It ran the targeted tests and fixed-sleep checks, and confirmed that cancelled reads return their slots without unhandled rejections. The reviewer also confirmed the evidence:
|
|
Merge pass review-work report. Overall: PASSED.
QA
Gate: real HTTP probes against an isolated server
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. |
Change
A signed-in device (a watch-only one included) could hold every one of the 16 read slots of
POST /api/connection-diagnosticsby sending each report body a byte at a time: the read had asize bound but no time bound, so every other report got 429 until those reads ended (#1425, item 1).
server/client-connection-log.ts: each body now has one 10 s deadline for the whole read, not aper-chunk timeout. A timer covers a body that stops arriving; a clock check after each chunk covers
one that keeps trickling. Past it the request gets 408
trace_timeout, the reader is cancelled,and the slot is released by the existing
finallyinhandle().shared/protocol.ts: the route's comment lists the new 408.src/lib/connectionTrace.test.tscloses every trace a test opens (a later test'sresumeConnectionTraces()reached earlier tests' traces), and the newsrc/lib/api-signin.test.tscovers
authenticateandpairDevice: request shape, reporting resumed after a successful sign-in,and not resumed after a refused one.
Items 2 and 3 are left as they are, as the issue describes them: the report quota is charged only
after validation so malformed posts cannot starve real ones (each parse is at most 8 KiB, 16 at once),
and a 4xx refusal drops that incident's batch by design (
connectionTrace.ts, tested); the 408 followsthat rule and the next incident still posts.
This adds a status code to an HTTP route's contract, so it needs a real review.
Fixes #1425
Verification
server/client-connection-log.test.ts: "ends a body that keeps trickling in once the deadline forthe whole body passes" (fake clock, no sleeps) and "gives every read slot back when the bodies holding
them stop arriving" (16 stalled bodies, 1 ms injected deadline). On origin/main they fail (413 / a 5 s
test timeout); on this branch they pass.
src/lib/api-signin.test.ts: removingresumeConnectionTraces()fromapi.tsfails the two"resume" cases; resuming before the
okcheck fails the two "refused" cases.createServer({ port: 0 })with 16 raw-TCP senders at one byte per second, rotatingX-Forwarded-For: this branch answers eachHTTP/1.1 408 Request Timeoutat 10.0 s and the nextreport gets 204; origin/main answers none of them within 20 s and the next report still gets 429.
Codex (gpt-6.1-sol, xhigh) APPROVE with no findings.
bun run check fast: workflow syntax, generated files, typecheck and build pass; unit tests6395 pass, 4 fail, all outside this change. Three in
server/shell-agent.test.tsfail with EMFILEfrom
fs.watch, on origin/main too: this PC is at its inotify instance limit (126 of 128) fromother sessions. One in
server/omp-process.test.tsis the readiness flake fix(tests): read omp-process test targets only once they are up #1862 and fix(omp): wait for process fixtures before reading procfs #1869 address;it passes when run alone.