Repository navigation
fix: don't shut down the reducer when the client closes the stream - #399
Merged
Merged
Conversation
ReduceFn in the async reducer is an async generator. When the client closes the response stream before reading every response, gRPC calls aclose() on it and GeneratorExit is thrown at the yield. The blanket except BaseException caught it, logged a UDF_EXECUTION_ERROR and set the shutdown event, so the UDF container exited with status 1. Return on GeneratorExit instead, as the reduce streamer already does since numaproj#331. A real exception at the same point still shuts down. Signed-off-by: Griff <grifftatarsky@gmail.com>
Codecov Report✅ All modified and coverable lines are covered by tests. Additional details and impacted files@@ Coverage Diff @@
## main #399 +/- ##
==========================================
+ Coverage 92.99% 93.10% +0.11%
==========================================
Files 68 68
Lines 3654 3656 +2
Branches 236 236
==========================================
+ Hits 3398 3404 +6
+ Misses 190 188 -2
+ Partials 66 64 -2 ☔ View full report in Codecov by Harness. 🚀 New features to boost your workflow:
|
grifftatarsky
marked this pull request as ready for review
December 3, 2026 19:48
grifftatarsky
requested review from
BulkBeing,
kohlisid and
vigith
as code owners
December 3, 2026 19:48
vigith
approved these changes
Dec 3, 2026
vigith
left a comment
Member
There was a problem hiding this comment.
I think we have the same problem in accumulator, mapstreamer, batchmapper, sinker and sourcer
Member
we will create in separate PR |
Contributor
Author
You want me to prep that? Happy to |
Member
thank you, could you please comment on #400 |
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.
Fixes #398
When the client closes the ReduceFn response stream early, gRPC calls
aclose()on the generator andGeneratorExitis thrown at theyield. The reducer'sexcept BaseExceptiontreated that as a UDF error and set the shutdown event, so the container exited with status 1. This adds the sameexcept GeneratorExit: returnthe reduce streamer got in #331.Tests, in
tests/reduce/test_async_reduce_shutdown.py:test_no_shutdown_when_stream_closed:aclose()after the first response sets neither the shutdown event nor_error.test_shutdown_on_error_at_yield: a real exception thrown at the sameyieldstill shuts down, so the newexceptonly covers stream close.test_no_shutdown_when_grpc_client_cancels: the same over a realgrpc.aioserver and client. The client cancels after one response; a client that reads everything is the control.The first and third fail without the change.
make testpasses on Python 3.11 and 3.14 (466 passed), black and ruff are clean, and the gRPC test passed 30 runs in a row.AI disclosure: the reproduction, the change, the tests and this description were prepared with an AI coding agent (Claude Code).