Commit 0258aa5
committed
fix(streaming): address greptile review findings
- _run: when CancelledError is raised mid-flush in the for-loop, re-enqueue
the in-flight item plus any remaining items in the local `drained` list
back into self._buf so close()'s final drain can recover them. Previously
the local `drained` list was unreachable after CancelledError exited the
for-loop, causing the last coalesced batch to be silently dropped on
close-during-flush races. Trade-off: the in-flight item may be duplicated
on the consumer side (Redis pub may have completed before cancel was
delivered), which is preferable to silent loss for streaming UX.
- _merge_pair: replace `return b` fallback with AssertionError. All six
current TaskMessageDelta variants have explicit isinstance branches, so
the fallback is unreachable today. But _can_merge returns True for any
same-type pair, so adding a 7th delta variant without updating
_merge_pair would silently drop `a`'s accumulated content. Asserting
turns a future silent data-loss into an immediate, diagnosable crash.1 parent 67c316d commit 0258aa5
1 file changed
Lines changed: 13 additions & 2 deletions
| Original file line number | Diff line number | Diff line change | |
|---|---|---|---|
| |||
122 | 122 | | |
123 | 123 | | |
124 | 124 | | |
125 | | - | |
| 125 | + | |
| 126 | + | |
| 127 | + | |
| 128 | + | |
126 | 129 | | |
127 | 130 | | |
128 | 131 | | |
| |||
189 | 192 | | |
190 | 193 | | |
191 | 194 | | |
192 | | - | |
| 195 | + | |
193 | 196 | | |
194 | 197 | | |
| 198 | + | |
| 199 | + | |
| 200 | + | |
| 201 | + | |
| 202 | + | |
| 203 | + | |
| 204 | + | |
| 205 | + | |
195 | 206 | | |
196 | 207 | | |
197 | 208 | | |
| |||
0 commit comments