Skip to content

Cut a streamed model answer only after its chunks reach the socket - #137

Merged
QuellaMC merged 1 commit into
mainfrom
fix/conformance-timing
Oct 20, 2026
Merged

QuellaMC merged 1 commit into
mainfrom
fix/conformance-timing

Conversation

@QuellaMC

Copy link
Copy Markdown
Owner

Summary

stream.shutdown-ends-streams, stream.slow-client-drop and model.provider-errors were not timing flakes. They fail on every run whose runner carries Node 24.22.0 and pass on every run with 24.21.0, which is why a re-run "fixed" them: GitHub is rolling the newer image out to part of its fleet. Eight of eight check jobs on the new image failed exactly these three, and eight of eight on the old image passed them.

The cause is in the conformance harness's stand-in model server, not in the daemon. These three tests are the only users of its end: 'cut' answer, which wrote the chunks and ended the socket in the same tick. Node 24.22.0 coalesces chunked writes during auto-corking (nodejs/node#64987) and hands the chunk to the socket a tick later, so the socket sent its FIN after the headers alone and the daemon saw a stream cut before any chunk, which it correctly reports as provider_error "terminated". Crossing versions settles the side: harness on 24.22 with the daemon on 24.21 fails, the reverse passes.

The cut now ends the socket from the write's own callback, which Node documents as firing once the chunk has been flushed. The response, not the socket, owns the order of its writes. No daemon code, inventory row, test title or bound changed, and no test was added: the three tests prove the cut end to end.

The other direct socket closes in the harness (the mem0, Telegram and relay stand-ins, and drop) fire before any response bytes or discard on purpose, so nothing else carries the same race.

Tests

Each test run 48 times, 12 at once, on main and on this branch:

Test main, Node 24.22.0 main, Node 24.20.0 fixed, Node 24.22.0 fixed, Node 24.20.0
stream.slow-client-drop 48 of 48 failed 0 of 48 0 of 48 0 of 48
stream.shutdown-ends-streams 48 of 48 failed 0 of 48 0 of 48 0 of 48
model.provider-errors 48 of 48 failed 0 of 48 0 of 48 0 of 48

The whole conformance project (24 files, 266 tests) and the browser suite (14 tests), which also uses the model server, pass on both Node 24.20.0 and 24.22.0. pnpm format:check, pnpm lint, pnpm typecheck, pnpm arch:check and the strict tsc pass.

Open: the local Node this repository is developed on (24.20.0) lags CI's 24.22.0, so a change that only shows under 24.22 is not caught locally until the local Node moves.

Node 24.22.0 holds a chunked write in the response until the next tick
(nodejs/node#64987), so the harness's cut ended the socket after the
headers alone, and the three tests that script a cut failed on every CI
runner carrying that Node: stream.shutdown-ends-streams,
stream.slow-client-drop and model.provider-errors. The cut now ends the
socket from the write's callback, which fires once the chunk is flushed.
@chatgpt-codex-connector

chatgpt-codex-connector Bot commented Oct 20, 2026 •

Copy link
Copy Markdown

Codex Review Summary

This comment shows the latest Codex review activity on this pull request.

Review Status Commit Review trigger
📝 Code Review ✅ Completed 2026-10-20T21:26:01.320320Z db386fe PR opened
ℹ️ About Codex in GitHub

Your team has set up Codex to review pull requests in this repo. Reviews are triggered when you

  • Open a pull request for review
  • Mark a draft as ready
  • Comment "@codex review" or "@codex security review".

Codex reacts with 👀 while any review is running, comments if it has suggestions, and reacts with 👍 once all reviews finish with no findings.

@QuellaMC
QuellaMC merged commit 7e6886f into main Oct 20, 2026
12 checks passed
@QuellaMC
QuellaMC deleted the fix/conformance-timing branch October 20, 2026 21:58
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

1 participant