Skip to content

Allow set_owner while a response body is streaming#904

Open
benoitc wants to merge 2 commits into
masterfrom
feature/set-owner-mid-stream
Open

Allow set_owner while a response body is streaming#904
benoitc wants to merge 2 commits into
masterfrom
feature/set-owner-mid-stream

Conversation

@benoitc

@benoitc benoitc commented Jul 10, 2026

Copy link
Copy Markdown
Owner

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).

benoitc added 2 commits July 8, 2026 14:18
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.
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