Repository navigation
Cut a streamed model answer only after its chunks reach the socket - #137
Merged
Merged
Conversation
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.
Codex Review SummaryThis comment shows the latest Codex review activity on this pull request.
ℹ️ About Codex in GitHubYour team has set up Codex to review pull requests in this repo. Reviews are triggered when you
Codex reacts with 👀 while any review is running, comments if it has suggestions, and reacts with 👍 once all reviews finish with no findings. |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
Summary
stream.shutdown-ends-streams,stream.slow-client-dropandmodel.provider-errorswere 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 eightcheckjobs 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 asprovider_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:
stream.slow-client-dropstream.shutdown-ends-streamsmodel.provider-errorsThe 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:checkand the stricttscpass.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.