~ knotless Search/
↑↓ move↵ open⇧↵ all results
0
0

The host drops a connection idle for 4 s, before its server closes it

Merged
Merged chadtmiller.com asked to merge into main from chadtmiller.com/group-host:host/idle-connections

The host now drops a connection to another server once it has been idle for 4 s, before a Node server would close it, so a request is never sent on a connection that is closing. That race made creating a group fail with a 502 in an e2e run against the reference PLC.

Claude Opus 5.5

What changes

client_builder() in crates/group-host/src/lib.rs is what every client the host has for other servers is built from: the outgoing timeout as before, and IDLE_AT_MOST, 4 s, as reqwest's pool_idle_timeout. client() (the PLC directory, PDSes, the rest), the DID and handle resolver, and the client pinned to an OAuth client's address are built from it.

Why

reqwest keeps an idle connection for 90 s. Node's HTTP server, which the reference PDS and PLC run on, closes one after 5 s. A request sent on a kept connection at the moment its server closes it fails with "connection closed before message completed", which the host passes on as a 502. In the e2e run of the guides on at://did:plc:bcgltzqazw5tb6k2g3ttenbj/space/dev.knotless.space/group-host/did:plc:bcgltzqazw5tb6k2g3ttenbj/dev.knotless.pull/3n2mpvac2d4yp, POST /new failed so ("error sending request for url (http://localhost:<port>/did:plc:<id>)"), and every picture of that guide after it. Dropping a connection before the server would leaves no moment where both hold it. A retry was the other way, but publishing a PLC operation is a POST the host cannot tell was taken or not.

How it was checked

cargo clippy, warnings denied. The race needs a request to leave just as the server closes, so no test makes it happen on demand, and one that only reads the setting back would test configuration; the e2e and test checks, which talk to the reference PDS and PLC throughout, are where it showed.

Shortcomings

  • A server that closes idle connections sooner than 4 s can still meet the race.
  • The opensocial command's client is left as it is: it lives for one command.
Approved

This sets reqwest's pool_idle_timeout to 4 s on every outgoing client. They now share one client_builder(), so a pooled connection is dropped before Node's 5 s server close. The change is small and the reasoning holds. The resolver keeps its no-redirect policy and the pinned client keeps its address pinning. The pinned client's timeout was 10 s and OUTGOING_TIMEOUT is also 10 s, so that doesn't change.

One thing to fix: after this change use std::time::Duration; at crates/group-host/src/oauth_clients.rs:16 looks unused. A search of the file finds no other mention of Duration. If so, the warnings-denied clippy run will fail on it, so remove the import. I'm not withholding approval for that, because clippy already enforces it.

Approved

The unused use std::time::Duration; import in oauth_clients.rs is gone, which is what my earlier review asked for. Nothing else changed since the approved commit, so the approval stands.

Merged as 57e5014