Allow set_owner while a response body is streaming#904
Open
benoitc wants to merge 2 commits into
Open
Conversation
Ownership could only be reassigned in the connected state; in receiving and streaming the set_owner event fell through to invalid_state. That tore the connection down when a short-lived worker exited mid-read, so a request run in one process could not be handed to a longer-lived reader. Handle set_owner (call and cast) in receiving and streaming: demonitor the old owner, monitor the new one, keep_state. The handlers stay minimal and do not touch the socket, active mode, or stream_to, so async delivery keeps its original target while only the lifecycle monitor moves.
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.
Ownership could only be reassigned in the connected state. In receiving and streaming the set_owner event fell through to invalid_state, so a connection whose response body was still being read could not be reparented. When a short-lived worker exited mid-read, receiving's owner-DOWN clause stopped the connection and the new reader got closed.
Handle set_owner (call and cast) in the receiving and streaming states, mirroring the connected handlers: demonitor the old owner, monitor the new one, keep_state. The handlers stay minimal and do not touch the socket, active mode, or stream_to, so async delivery keeps its original target while only the lifecycle monitor moves. connected, closed and streaming_once are unchanged.
Tests: mid-stream handoff over HTTP/1.1, the async streaming path, and a regression test pinning set_owner in connected (still ok) and streaming_once (still invalid_state).