chadtmiller.com/monolith
An atproto PDS
pds-server: a body left unread is read after the answer, its connection kept
MergedThis pull makes limits::serve add Connection: close to any answer given before the request body was read to its end. That fixes the nightly "socket hang up". The Idle wrapper's ended flag starts true for bodyless requests, so GETs and the firehose upgrade are not affected. I found no bugs.
- Spec:
spec/LIMITS.mdcarries the new rule and the new check, and the changeset is written for people who run or call the server. - Harness:
refusedBodiesis a new check and does not loosen an existing one. It names what it compares. The helpers it uses (connect,sized,reach) exist. - Server code: it uses no atproto or MCP crates.
I did not run anything; the review is from reading the diff.
Nothing changed in the pull itself since my approval at 7d680e7. The new head adds a changeset, .changeset/lettre-0-11-24.md, and a Cargo.lock bump of lettre to 0.11.24 and email-encoding to 0.4.3. These look like main's changes merged in, not this pull's. They are patch-level dependency updates, and the changeset is written for people who run the server. They don't touch the limits::serve fix, the spec or the refusedBodies check, so my earlier approval stands. I read the diff only and ran nothing.
The head ac9bc19 has no code differences from 7c931d3, which I approved. So the title or body changed, not the pull's content. The pull still does what it says. limits::serve adds Connection: close to any answer given before the request body was read to its end. The spec in spec/LIMITS.md and the changeset agree with the code. The new refusedBodies check names what it compares. I read the diff and ran nothing.
Approve. The change since my approval at ac9bc19 is the one the title and body describe: after the answer, the server reads and throws away what is left of a body it answered without, instead of closing the connection.
- Server:
Idlenow hands the rest of a body back toserveif it is dropped unread.servespawnsdrainwhen theContent-Lengthleaves at most 4 MiB. Otherwise, including a chunked body, it addsConnection: close.- A body that is never dropped before the answer, or one with no exact length, gets
Connection: close. That is the safe fallback. draingives up after 30 s with no data, so a stalled client can't hold it open.
- A body that is never dropped before the answer, or one with no exact length, gets
- Spec and changeset:
spec/LIMITS.mdand the changeset describe this behaviour, and the check list in the spec has the new case. - Harness:
refusedBodiesis stricter for the server, which must now keep the connection. It still allows the reference either to keep the connection or to sayConnection: close. The new CSRF-refusal case names what it compares. The step is added tocompare.mjs.
I read the diff and ran nothing.
3 passed, 1 skipped
The 2026-11-19 nightly failed on a "socket hang up" in a crash run. The server answered an oversized OAuth sign-in with
413and closed the connection without saying so, and the harness sent its next request on that closed connection. Now the server reads and throws away whatever is left of a body it answered without (up to 4 MiB), so the connection stays usable. A new harness check fails every time against the old server.Claude Opus 5.5 · high
What changes
Spec.
spec/LIMITS.md, "Request size": when a request is answered before its body was read to its end and itsContent-Lengthleaves at most 4 MiB unread, the connection is kept. The server reads the rest after the answer and throws it away. A body with more left than that, or one sent chunked, getsConnection: close, and the connection is closed after the answer. "How it is checked" lists the new check.Harness. A new random step,
refusedBodiesinharness/checks/limits.mjs(weight 2). It sends one of four requests, each with aContent-Lengthand on a raw connection of its own:createRecordone byte past its cap.On the server, the same connection must then answer
GET /xrpc/_health, sent 100 ms later. The reference may do that or sayConnection: close; it keeps the connection in each case seen. Statuses are compared.Server. In
limits::serve, theIdlebody wrapper records when the body was read to its end. If a handler drops the body before then, the wrapper hands what's left back toserve. After the answer is ready,servespawnsdrainto read and throw away the rest when theContent-Lengthleaves at mostDRAIN(4 MiB), stopping if it sends nothing for 30 s. Otherwise it addsConnection: closeto the answer.Why
Nightly
crashfailed at--seed 21 --crash-every 15, step 186:createInviteCodescame backrequest failed: socket hang upon the server's side and 200 on the reference's. The server's log ends at the step before, an OAuth sign-in answered413in 0.04 ms. ThecreateInviteCodesrequest never reached the server.oauth::read_body(PAR and the sign-in API) refuses byContent-Lengthwithout reading the body. When the body is dropped unread, hyper tries one read; if the body isn't complete it gives up and closes the connection after the answer. It often notices only after writing the answer's head, so the answer goes out with keep-alive and noConnection: close. Node's HTTP agent, which the harness'ssendandBrowser.requestuse, keeps that socket for the next request. If that request leaves before Node sees the close, it goes out on a closed connection. Whether it fails depends on timing.The first version of this pull only added
Connection: closewhenever a body was left unread. That also closed connections hyper used to keep: small bodies refused before being read, whose bytes hyper's one read had already taken. A draft pull that printed each close (closed now) showed these on the runner:passkey-registerand sign-in400s, andPOST /oauth/passkey404s, sent by the random steps' passkey and sign-in checks. Reading the rest of the body is what the reference does. It keeps those connections and closes none that hyper used to keep, so this version does that.How it was checked
node compare.mjs --steps 40 --seed 1 --only refusedBodies, against three servers:main: fails at step 1. PAR's413saysConnection: close, which the check no longer accepts for a body this small.main's handling and the close-only handling, and each fails the check. Earlier, againstmain's server, the sign-in case failed withread ECONNRESETon the next request.--pages --seed 1three times at its passkey flows (step 31), each on a different check, and passed it on the draft pull. With this version's server, instrumented, no request in a pages run here was drained or closed, so the pages run does not reach the new code. Here,--pages --seed 1passed 8 runs out of 10 with this version, the 4 at once among them, and 10 out of 10 withmain's server. The 2 failures were in the passkey flows: a navigation interrupted twice, and a sign-in page whose assets never loaded.Shortcomings