Commit ad8d267
fix(streaming): don't dispatch empty SSE keepalive comment frames
The SSE decoder's empty-block guard included last_event_id, which is sticky
across events per the SSE spec. Once any event carried an id, every subsequent
comment-only block (e.g. the server's ":\n\n" keepalive, sent every 15s on an
idle stream) fell through the guard and dispatched an empty-data event. The
typed Stream wrapper then calls .json() on it unconditionally, raising
JSONDecodeError and killing the stream.
This made idle browser telemetry streams crash after ~15s. Drop last_event_id
from the guard so dispatch depends only on the current block's event/data/retry
fields. Event-typed empty-data frames still dispatch (unchanged). Adds a
regression test for a keepalive comment following an id-bearing event.
Co-Authored-By: Claude Opus 4.8 (1M context) <noreply@anthropic.com>1 parent 6cdb613 commit ad8d267
2 files changed
Lines changed: 32 additions & 1 deletion
| Original file line number | Diff line number | Diff line change | |
|---|---|---|---|
| |||
251 | 251 | | |
252 | 252 | | |
253 | 253 | | |
254 | | - | |
| 254 | + | |
| 255 | + | |
| 256 | + | |
| 257 | + | |
| 258 | + | |
| 259 | + | |
255 | 260 | | |
256 | 261 | | |
257 | 262 | | |
| |||
| Original file line number | Diff line number | Diff line change | |
|---|---|---|---|
| |||
26 | 26 | | |
27 | 27 | | |
28 | 28 | | |
| 29 | + | |
| 30 | + | |
| 31 | + | |
| 32 | + | |
| 33 | + | |
| 34 | + | |
| 35 | + | |
| 36 | + | |
| 37 | + | |
| 38 | + | |
| 39 | + | |
| 40 | + | |
| 41 | + | |
| 42 | + | |
| 43 | + | |
| 44 | + | |
| 45 | + | |
| 46 | + | |
| 47 | + | |
| 48 | + | |
| 49 | + | |
| 50 | + | |
| 51 | + | |
| 52 | + | |
| 53 | + | |
| 54 | + | |
29 | 55 | | |
30 | 56 | | |
31 | 57 | | |
| |||
0 commit comments