fix: check [DONE] SSE marker before deserialization in stream_mapped_raw_events#543
Merged
Merged
Conversation
…raw_events PR #537 refactored the streaming pipeline and removed reqwest-eventsource. The old `stream()` function checked for the `[DONE]` SSE end-of-stream marker *before* passing event data to `serde_json::from_str`. The refactored version delegated to `stream_mapped_raw_events`, which checks `[DONE]` *after* calling the `event_mapper` closure. Since the mapper in `stream()` deserializes JSON, this causes `[DONE]` to fail with: failed deserialization of: [DONE] Move the `[DONE]` check before the mapper call in both the WASM (futures::stream::unfold) and non-WASM (tokio::mpsc) implementations. Closes #542
Owner
|
I was trying to reduce duplicate functions - good catch and thanks for the fix! |
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
Fixes #542 —
[DONE]SSE end-of-stream marker being passed toserde_json::from_strinstream(), causing a deserialization error.Root Cause
In v0.36.0 (PR #537), the streaming pipeline was refactored to remove
reqwest-eventsource. The oldstream()function checked for[DONE]before deserialization. The newstream()delegates tostream_mapped_raw_events, which checks[DONE]after the mapper closure — and the mapper instream()isserde_json::from_str.Fix
Move the
[DONE]check before theevent_mappercall in both implementations:futures::stream::unfold): Check[DONE]and returnNoneto end the stream cleanly. Removed thefinishedstate variable since it's no longer needed.tokio::mpsc): Check[DONE]andbreakbefore callingevent_mapper.Test Plan
Before
After