Repository navigation
fix(eventStream): propagate source errors and unblock the deflate relay - #554
Merged
awatson1978 merged 1 commit intoSep 30, 2026
Merged
Conversation
Review findings 6 and 7, both HIGH, both previously only partially fixed on this branch. Finding 6: the deflate relay throttle parked solely on bodyStream.awaitConsumerActivity() while the body-loop catch awaited relayPromise, so a listener that threw mid-parse left each side waiting for the other and the returned promise never settled. The body catch now resolves a bodyFailed deferred before awaiting the relay, and the relay races that deferred inside its throttle gate and winds down. Finding 7: feedError was only re-checked in the raw-dataset fallback and the deflate relay; the normal native completion path treated a source error's setComplete() as a clean EOF. The clean path now awaits the feed and throws feedError before endDataSet, and the body catch prefers inflateError ?? feedError ?? bodyErr so the root cause is what surfaces. Tests: a throwing listener on the deflate fixture pins the deadlock (promise must settle within a timeout), and an async-generator source that throws after N bytes — cut at an element boundary (1044) and mid-element (1000), both probed against the pre-fix reader — pins that the source's own error is what the caller sees. Co-Authored-By: Claude Fable 5 <[email protected]>
This was referenced Sep 30, 2026
|
🎉 This PR is included in version 1.0.0-beta.1 🎉 The release is available on:
Your semantic-release bot 📦🚀 |
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.
Two HIGH findings from the streaming-reader review land here together, because they are two halves of the same failure story: what happens when something goes wrong mid-stream. Finding 6 is a deadlock; finding 7 is a silently swallowed error. Both had been partially addressed on this branch — the deep paths (raw-dataset fallback, the deflate relay) already checked for a failed source — but the two most ordinary paths did not.
Finding 6 first. On the deflate path a relay coroutine inflates compressed bytes into a side stream that the body loop consumes, and a throttle keeps the relay from ballooning memory: when more than 16 KiB of inflated output is sitting unconsumed, the relay parks on
bodyStream.awaitConsumerActivity(). The problem: if the body loop dies — concretely, if the listener throws during an event callback — there is no consumer anymore, so that activity never comes. Meanwhile the body loop's catch handler doesawait relayPromiseto collect any inflate error before rethrowing. Each side waits for the other, forever, and the promise returned fromfromPart10Streamnever settles. The fix is abodyFaileddeferred: the body catch resolves it before awaiting the relay, and the relay races it inside the throttle gate, sees the flag, and winds down.Finding 7 is quieter and nastier. The feed loop that pulls chunks from your source catches a source error into
feedError— and then callssetComplete()so blocked readers wake up. But the normal completion path never looked atfeedErroragain: to the body loop, a source that died at a top-level element boundary is indistinguishable from a file that genuinely ended there. I probed this against the pre-fix reader on the CT1_UNC explicit-LE fixture: a source that throws after 1,044 bytes resolved cleanly, handing the caller a well-formed-looking dataset with a fraction of the file's tags and no signal that the transfer failed. A cut mid-element (1,000 bytes) did reject — but with the downstream symptom (truncated: element at 998 declares 8 bytes but stream ended) instead of the source's own error. Now the clean-EOF path awaits the feed and throwsfeedErrorbeforeendDataSet, and the body catch prefersinflateError ?? feedError ?? bodyErr, so the root cause is what surfaces.The tests pin all three behaviors. The deadlock test is the finding's own reproduction:
And the source-error tests use an async generator that yields the first N bytes and then throws
NETWORK BOOM, at both probed cut points — the boundary cut that used to resolve cleanly and the mid-element cut that used to mask the cause. Both now reject with the source's error. All three tests were verified failing (the deadlock one by hang-then-timeout) before the fix went in; the full suite is green at 634 passing.🤖 Generated with Claude Code