fix: decode every complete SSE event already in the buffer #7
Reference in New Issue
Block a user
Delete Branch "fix/sse-decode-loop"
Deleting a branch is permanent. Although the deleted branch may continue to exist for a short time before it actually gets removed, it CANNOT be undone in most cases. Continue?
Fixes #6
Summary
ServerSentEventsCodec::decodenow loops over lines until an event is complete, and returnsOk(None)only when no full line is left in the buffer. Before, it returnedOk(None)after every non-empty line, which madeFramedReadwait for the next network read even though the rest of the event was already buffered.retry:value now skips to the next line (continue) instead of returning early, so the event it belongs to is still returned.decode_eof). This is the same fix as andreban/geologia#24.Testing
src/network/event_source_tests.rs:retrydoesn't stop the event from being returneddecodeand pass with the fix.cargo clippy --all-targets -- -D warningsandcargo testpass.cargo fmt --checkfails onmainalready, inexamples/*,src/client.rsandsrc/client_tests.rs, none of which this PR touches. The files changed here are formatted.examples/text-from-text-streaming.rsagainst Vertex AI and check that chunks print as they arrive instead of in bursts.