Repository navigation
Conversation
shsms
force-pushed
the
stream-idle-timeout
branch
from
October 21, 2026 15:04
da79257 to
1604390
Compare
The retry count of GrpcStreamBroadcaster was never reset, so a retry limit counted every retry over the life of the stream. A long-running stream with a limit gave up after that many lost connections, even when it had recovered from each one. Reset the count when a message arrives, so a limit counts the retries since the last message. Signed-off-by: Sahas Subramanian <sahas.subramanian@proton.me>
A server stream that stays open without sending blocked its consumers forever. Cancel such a call and retry it like a failed one. Signed-off-by: Sahas Subramanian <sahas.subramanian@proton.me>
Abandoned streams kept retrying forever, so abandoned broadcasters piled up calls during outages. Track the receivers handed out and stop once all are closed or dropped, also while stalled or retrying. Also end the receivers on any exit of the stream: an unexpected error left them waiting forever. Now they end, and receivers with events get a StreamFatalError. And let stop() pass on a cancellation of its caller, which it used to swallow. A receiver with events requested after the stream stopped now ends at once too. If no receiver with events existed before, it used to wait on a new event channel that was never closed. Signed-off-by: Sahas Subramanian <sahas.subramanian@proton.me>
Some clients reuse a cached broadcaster without checking is_running, so a stream stopped for lack of receivers would hand them a receiver that ends without data. Start a new run instead. Each run already closes only its own channels, so the old run winding down cannot end the new run's receivers. A stream that ended, gave up or failed by itself is not restarted. Signed-off-by: Sahas Subramanian <sahas.subramanian@proton.me>
shsms
force-pushed
the
stream-idle-timeout
branch
from
November 3, 2026 10:30
1604390 to
cacddab
Compare
This branch has not been deployed
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.
A
GrpcStreamBroadcasterwhose server stream went silent, or whose receivers were all dropped, kept its call open and could retry forever. This branch adds an opt-in idle timeout, stops a stream once every receiver it handed out is gone, and starts it again for the next receiver.Changes
retry_strategylimit counts the retries since the last message.idle_timeout(opt-in): a call that receives no message for that long is cancelled and retried like a failed call, with aStreamIdleTimeoutError._Run, with no behavior change, so one run can stop while a new one starts.stop()passes on its caller's cancellation;stop()and event-loop shutdown no longer hang on a call that turns its cancellation into a gRPC error or into the end of the stream. Another error raised while the run is being cancelled is logged as a warning, not sent as aStreamFatalError.new_receiver()returns a wrapper. When every receiver is closed or garbage-collected, the run is cancelled, also while it is stalled or retrying. A broadcaster that never handed out a receiver keeps running.new_receiver()starts a new run with a fresh copy ofretry_strategy, unlessstop()was called or the stream ended by itself.GrpcStreamBroadcaster.new_receiver(): it counts the receiver before creating it, setshanded_out, and restarts the run._ReceiverCounterand_TrackedReceiver.Breaking
new_receiver()now returns a wrapperReceiver:len()andMerger.stop()no longer work.is_runningis then False. Keep a receiver referenced while you read from it.retry_strategylimit no longer caps the total number of retries.StreamFatalError.exceptioncan now be an error that is not a gRPC error.