Skip to content

Commit 0dc7142

Browse files
committed
fix(core): keep bufferSeqNums in lock-step on session-stream on()-drain
`on()`'s buffer-drain block called `this.buffer.delete(key)` after handing buffered records to the new handler but didn't delete the parallel `this.bufferSeqNums` entry. The next `#dispatch` that buffered a record would then append onto the orphaned seqNum array, and a subsequent `once()` / `shiftBuffer()` would advance `lastDispatchedSeqNum` with a stale seq — which would land on the next `turn-complete` control record's `session-in-event-id` header and cause the next worker boot to under-skip `.in`. Matches the cleanup pattern already used in shiftBuffer / disconnectStream / reset.
1 parent ffc52b4 commit 0dc7142

1 file changed

Lines changed: 4 additions & 0 deletions

File tree

packages/core/src/v3/sessionStreams/manager.ts

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -113,6 +113,10 @@ export class StandardSessionStreamManager implements SessionStreamManager {
113113
this.#invokeHandler(handler, data);
114114
}
115115
this.buffer.delete(key);
116+
// Keep `bufferSeqNums` in lock-step with `buffer` — without this,
117+
// the parallel array desyncs and the next `#dispatch` that buffers
118+
// a record would shift a stale seqNum into `lastDispatchedSeqNum`.
119+
this.bufferSeqNums.delete(key);
116120
}
117121

118122
return {

0 commit comments

Comments
 (0)