[v1.x] Buffer per-request StreamableHTTP streams; store priming event before dispatch#2948
Open
maxisbey wants to merge 1 commit into
Open
[v1.x] Buffer per-request StreamableHTTP streams; store priming event before dispatch#2948maxisbey wants to merge 1 commit into
maxisbey wants to merge 1 commit into
Conversation
… before dispatch Backport of #2934. Gives the per-request _request_streams[EventMessage] sites a small bounded buffer (REQUEST_STREAM_BUFFER_SIZE = 16) so the serial message_router can deposit a response and move on instead of head-of-line blocking the session on a lazily-started sse_writer. Replaces _maybe_send_priming_event with _mint_priming_event (stores + returns the wire dict) and extracts the inline sse_writer closure to _run_sse_writer. The POST handler now mints priming before any per-request state is registered and before the request is dispatched, so the priming row precedes anything message_router can store for that stream by data dependency. Adds a finally to replay_sender; uses a generic 500 body in the outer except. Fixes #1764.
felixweinberger
approved these changes
Jun 22, 2026
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.
Backport of #2934.
Buffers the per-request
_request_streams[EventMessage]channels (REQUEST_STREAM_BUFFER_SIZE = 16) so the serialmessage_routercan deposit a response and move on instead of head-of-line blocking the session on a lazily-startedsse_writer; and stores the priming event before the request is dispatched so its event-store position precedes anythingmessage_routercan store for that stream by data dependency.v1.x adaptations vs main
_run_sse_writerchecksevent_message.message.root(v1.x'sJSONRPCMessageis aRootModel)._mint_priming_eventkeeps v1.x'sprotocol_version < "2025-11-25"string compare (nois_version_at_leaston this branch).tests/interaction/transports/which doesn't exist on v1.x; instead, the three_maybe_send_priming_eventunit tests are rewritten against_mint_priming_eventto keep the no-store / old-pv / retry-field branches covered._run_sse_writercarries a# pragma: no covermatching the closure it replaces (v1.x's coverage of that path is subprocess-only and the branch has nostrict-no-cover).Motivation and Context
Fixes #1764.
How Has This Been Tested?
tests/server/test_streamable_http_router.py(HOL test + priming-failure test, withJSONRPCMessage(...)wrapping for the RootModel).tests/shared/test_streamable_http.pypriming unit tests rewritten for_mint_priming_event.Breaking Changes
None.
Types of changes
Checklist
AI Disclaimer