SSE decoder holds each event until the next network read #6
Reference in New Issue
Block a user
Delete Branch "%!s()"
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?
Problem
stream_generate_contentdelivers events late, so streamed output arrives in bursts or all at once at the end instead of as it is generated.ServerSentEventsCodec::decode(src/network/event_source.rs) reads one line per call and returnsOk(None)after any line that doesn't end an event (data:,event:, ...).FramedReadtreatsOk(None)as "need more bytes", so it waits for the next network read before callingdecodeagain, even when the empty line that ends the event is already in the buffer.As a result, each event is held back until more bytes arrive. When one read holds several events, they come out one per later read, and whatever is left is only flushed when the stream ends.
Fix
Loop in
decodeuntil an event is complete or no full line is left in the buffer. This is the same fix as andreban/geologia#24.