fix: stream errors to client before breaking generator loop - #587
Open
Swigler wants to merge 1 commit into
Open
Conversation
Since v1.7.7 (PR runpod#384), when a generator handler yields an error the code breaks out of the streaming loop before calling stream_result(), so the error is never delivered to clients listening on /stream. The error is saved for /status but the stream goes silent. Additionally, the error extraction stripped all extra fields (context, refresh_worker, etc.) by replacing the dict with {"error": msg}. - Call stream_result() with the error BEFORE breaking out of the loop - Preserve extra fields from the error dict alongside the error message - Add tests for both streaming delivery and field preservation Closes runpod#397
Swigler
force-pushed
the
fix/stream-error-delivery
branch
from
September 3, 2026 17:56
de830dd to
998a999
Compare
Author
|
Ping — errors during streaming are swallowed because the generator breaks before sending. This streams the error to the client first. Ready for review. |
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.
Summary
stream_result()is called with the error before breaking out of the generator loopcontextandrefresh_workersurvive error extraction instead of being strippedFixes #397
What was wrong
Since v1.7.7 (PR #384), when a generator handler yields an error, the code in
handle_job()breaks out of the streaming loop before callingstream_result():Clients listening on
/streamreceive normal chunks fine, but when an error occurs the stream goes silent. The error is saved internally (visible via/status), but never delivered through the stream.Additionally, the error extraction replaced the entire dict:
This discarded all other fields (
context,refresh_worker, etc.).PR #384's intent (marking errored jobs as FAILED instead of COMPLETED) is preserved —
send_result()still receivesjob_resultwith the error and sets the correct status.What changed
rp_job.py—handle_job()generator loop:await stream_result(session, stream_output, job)beforebreakso errors reach the streamtest_job.py— 2 new tests:Test plan
test_job.pypass (29 existing + 2 new)stream_resultis called twice (once for normal chunk, once for error)context,refresh_worker) are present in streamed error