Commit 0d5e212
committed
fix(core,sdk): drain cursor, scan timeout, seqNum NaN guard
Three small follow-ups from the code-review pass.
`StandardSessionStreamManager.on()`'s buffer-drain now advances the
committed-consume cursor (`lastDispatchedSeqNums`) to the highest
buffered seq before deleting the buffer. Drained records are removed
from the buffer and no longer reachable via `once()`, so they're
effectively consumed from the manager's perspective — without the
advance, a worker using `messagesInput.on()` (pendingMessages mode)
would persist a `.in` cursor that lags behind records the handler
already processed and the next boot would re-deliver them.
`findLatestSessionInCursor`'s `timeoutInSeconds` raised from 1 to 5.
S2 trim is eventually-consistent over 10-60s; a worker booting just
after a trim could still see pre-trim records, and 1s isn't always
enough headroom to drain them and read the latest turn-complete header
before the SSE long-poll closes. Without the cursor seed, `.in` opens
from seq=0 and the slim-wire merge catches the dupes — correct but
the optimization is silently lost.
`subscribeToSessionStream`'s control-event dispatch replaces
`Number.parseInt(part.id, 10) || 0` with an explicit `Number.isFinite`
guard that drops the event when the id is non-numeric, rather than
firing `onControl` with a misleading `seqNum: 0`. Doesn't matter in
practice (S2 always emits numeric ids), but `findLatestSessionInCursor`
and the dashboard rely on the seqNum being meaningful for resume.1 parent f8f9898 commit 0d5e212
3 files changed
Lines changed: 33 additions & 2 deletions
| Original file line number | Diff line number | Diff line change | |
|---|---|---|---|
| |||
1346 | 1346 | | |
1347 | 1347 | | |
1348 | 1348 | | |
| 1349 | + | |
| 1350 | + | |
| 1351 | + | |
| 1352 | + | |
| 1353 | + | |
| 1354 | + | |
| 1355 | + | |
| 1356 | + | |
| 1357 | + | |
| 1358 | + | |
| 1359 | + | |
1349 | 1360 | | |
1350 | 1361 | | |
1351 | 1362 | | |
1352 | | - | |
| 1363 | + | |
1353 | 1364 | | |
1354 | 1365 | | |
1355 | 1366 | | |
| |||
| Original file line number | Diff line number | Diff line change | |
|---|---|---|---|
| |||
118 | 118 | | |
119 | 119 | | |
120 | 120 | | |
| 121 | + | |
| 122 | + | |
| 123 | + | |
| 124 | + | |
| 125 | + | |
| 126 | + | |
| 127 | + | |
| 128 | + | |
| 129 | + | |
| 130 | + | |
| 131 | + | |
| 132 | + | |
| 133 | + | |
| 134 | + | |
121 | 135 | | |
122 | 136 | | |
123 | 137 | | |
| |||
| Original file line number | Diff line number | Diff line change | |
|---|---|---|---|
| |||
178 | 178 | | |
179 | 179 | | |
180 | 180 | | |
181 | | - | |
| 181 | + | |
| 182 | + | |
| 183 | + | |
| 184 | + | |
| 185 | + | |
| 186 | + | |
| 187 | + | |
182 | 188 | | |
183 | 189 | | |
184 | 190 | | |
| |||
0 commit comments