What changed: a reply body's Read now ends bodyIdleWait (five minutes)
after the last byte the plugin sent, gives the fetch up and says so,
when nothing more comes. The wait is between bytes, not the reply's
whole length: every chunk resets it, so a stream a slow model keeps
fed goes on however long it talks.
Why: a network drop mid-stream can leave a local proxy's socket open
but soundless, and a plugin body's read ended only on a chunk, an
answer, a close, a cancelled ctx or the host's death — none ever came,
so the request hung until the client cancelled it, with no error frame
and no retry (#4934). The gateway's relay already ends a stream whose
read fails with a protocol-valid error event; what the plugin leg
lacked was any read that fails. Five minutes is the silence the
gateway itself holds a client through (keepaliveLongest) before
leaving a stuck stream to a timeout; this is that timeout for a
plugin's reply. The wait for the reply's head is another wait and
stays as it was — this issue is a stream already past its first token.
Run: the new TestHostBodyIdleEndsASilentStream failed before the fix
(a read held for ever) and passes after; TestHostBodyIdleSparesAFedStream
locks the between-bytes reading. go test ./internal/plugin/
./internal/gateway/ ./internal/provider/ -tags nogui, the host tests
under -race, gofmt, go vet and go build all pass, with pre-existing
failures on this machine only (TestHostToldTheGatewayAddress, also red
on a clean upstream/main; TestCodexPoolSaysTheClientsVersion, the known
flake, green on a rerun).
Review, changed from ggbdpq's patch: the wait is thirty minutes, not
five. Five minutes cut replies that are silent for their whole
generation and come in one burst at the end (a model at its highest
effort, a relay that buffers its reply): those run past ten minutes,
and the gateway already keeps a translated reply's client alive
through thirty (translatedQuietLongest). A dead connection's read now
ends at that bound instead of never; the reporter's 4m52s case still
waits on the client to cancel first, which is the trade. The text
above that says five minutes and keepaliveLongest is the patch's
first version.
Broken by hand at the reviewed head: the idle timer (its start and
its reset) set to 1000h, TestHostBodyIdleEndsASilentStream red after
its 5s bar; restored, green. TestHostBodyIdleSparesAFedStream guards
against a whole-reply deadline, not a mutation of this code: with the
reset taken out it stays green (a stopped timer never fires).
Run at the pushed tree (this stack of nine on origin/main 3c2dceb34),
on mote (macOS arm64, Go 1.26.8):
- go test -count=1 -timeout 45m ./internal/catalog/...
./internal/plugin/... ./internal/davsync/... ./internal/gateway/...:
catalog, plugin and davsync ok; gateway red on one test only,
TestCodexPoolSaysTheClientsVersion, the open #4807 (another test's
Codex identity reaches it in a full package run). It passes run
alone at this tree, 3 of 3.
- go vet ./... (darwin); GOOS=linux and GOOS=windows go vet -tags
nogui ./...: ok. gofmt -l on every tracked .go file: clean.
- The hand breaks above ran on this stack before its rebase onto
3c2dceb34. That commit changed member.go only, nothing these tests
reach.
Not tried: the GUI suite, since no GUI file changed. Windows and Linux
test runs (the Claude bridge tests use a shell fake and skip on
Windows). No real vendor, Claude Code or network was used; every
case runs against fakes.
Generated-by: GLM-5.3-Flash (ZCode)