fix(batch): surface background stream failures on exit instead of returning partial results - #2141
Open
g-despot wants to merge 1 commit into
Open
fix(batch): surface background stream failures on exit instead of returning partial results#2141g-despot wants to merge 1 commit into
g-despot wants to merge 1 commit into
Conversation
This was referenced Aug 21, 2026
There was a problem hiding this comment.
Orca Security Scan Summary
| Status | Check | Issues by priority | |
|---|---|---|---|
| Infrastructure as Code | View in Orca | ||
| SAST | View in Orca | ||
| Secrets | View in Orca | ||
| Vulnerabilities | View in Orca |
Codecov Report❌ Patch coverage is Additional details and impacted files@@ Coverage Diff @@
## main #2141 +/- ##
==========================================
+ Coverage 86.64% 88.66% +2.01%
==========================================
Files 300 306 +6
Lines 23172 23757 +585
==========================================
+ Hits 20077 21063 +986
+ Misses 3095 2694 -401 ☔ View full report in Codecov by Harness. 🚀 New features to boost your workflow:
|
…urning partial results - _wait() raises the recorded background exception in both colours (or a WeaviateBatchStreamError naming the objects/references left unsent when the tasks/threads are gone); partial results are still copied first so batch.failed_objects can be inspected after catching - leaving `with`/`async with client.batch.stream()` raises that failure on a clean block (the sync colour previously swallowed it); an exception raised inside the block wins and the background failure is only logged - async flush() checks the background tasks each tick, like the sync colour, so a task that died without recording an exception raises instead of spinning forever; "died unexpectedly" is a WeaviateBatchStreamError instead of a bare Exception - sync _start() raises the stored background error at once instead of polling for 60 s and blaming the network (defect 4 of #2139) - _BatchStreamShutdownError is a WeaviateBatchStreamError, since it can now reach users on a server-side ABORTED Co-Authored-By: Claude Fable 5 <noreply@anthropic.com> Claude-Session: https://claude.ai/code/session_01GUNU7QgDr9MmFZnjKY9zFN
g-despot
force-pushed
the
fix/batch-stream-surface-failures
branch
from
August 21, 2026 17:46
f2e3e11 to
f1dc88a
Compare
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.
Why
Split out of #2056: a behaviour change for
client.batch.stream()/collection.batch.stream()on every platform, so it gets its own review. (#2056 stays open for reference; siblings: #2140 token-refresh fixes, #2142 the trimmed WASM transport.)Today a background failure in the stream (the recv/loop task or thread dying, or the server ending the stream early) is only noticed if the user calls
add_object()/flush()afterwards. If it happens after the last add, leaving thewithblock returns normally with partial results — silent data loss. The sync__exit__never raised at all.What changes
_wait()(both sync and async) raises the recorded background exception, or aWeaviateBatchStreamErrorsaying how many objects/references were left unsent when the background tasks/threads are gone. Partial results are still copied first, sobatch.results/batch.failed_objectscan be inspected after catching.with/async with batch.stream()raises that failure on a clean block. If the block itself raised, that exception wins and the background failure is only logged.flush()checks the background tasks each tick (the sync one already did), so a task that died without recording an exception raises instead of spinning forever. "Died unexpectedly" is aWeaviateBatchStreamErrorinstead of a bareException._start()raises the stored background error as soon as a thread has died, instead of polling for 60 s and then blaming the network — defect 4 of Batch stream recovery closes the shared connection and can leave the client permanently closed #2139 (the__reconnectshared-connection defects 1–3 there are not addressed here)._BatchStreamShutdownError(gRPC ABORTED) is now aWeaviateBatchStreamErrorsubclass, since it can reach users on exit.What users will notice
may now raise
WeaviateBatchStreamErrorat the end of the block where it previously returned silently with unsent data. That is the point, but it is a behaviour change.Tests
test/test_batch_stream_async.py(4) /test/test_batch_stream_sync.py(5), unit tests over the private internals, no cluster:_waitraises and keeps partial results, unsent-data message,flushwith a dead task,_startwith a stored error (fails onmainafter the 60 s timeout), and the context-manager rules (clean block raises; the user's exception wins).test/+mock_tests/test_batch.pypass locally; ruff / flake8 / pyright clean.