Skip to content

Commit 1966009

Browse files
authored
fix: Reset chunk tracking on session reattach (#65)
1 parent 1c0e195 commit 1966009

File tree

2 files changed

+16
-0
lines changed

2 files changed

+16
-0
lines changed

src/OutgoingConnection.ts

Lines changed: 10 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -541,6 +541,16 @@ export class OutgoingConnection {
541541
}
542542
}
543543

544+
/**
545+
* Reset chunk tracking state. Call this when the session is reattached to a new WebSocket
546+
* to prevent frames from being discarded as "reordered" when chunk numbers restart from 0.
547+
*/
548+
resetChunkTracking(): void {
549+
logger.info(`Resetting chunk tracking for tag ${this.localTag} (was lastChunkNo=${this.lastChunkNo})`);
550+
this.lastChunkNo = -1;
551+
this.lastTimestamp = -1;
552+
}
553+
544554
close(): void {
545555
this.doClose(false);
546556
}

src/transcriberproxy.ts

Lines changed: 6 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -269,6 +269,12 @@ export class TranscriberProxy extends EventEmitter {
269269
// Re-setup listeners on new WebSocket
270270
this.setupWebSocketListeners();
271271

272+
// Reset chunk tracking on all connections so frames from the new client
273+
// aren't discarded as "reordered" (chunk numbers restart from 0)
274+
this.outgoingConnections.forEach((connection, tag) => {
275+
connection.resetChunkTracking();
276+
});
277+
272278
logger.info(
273279
`WebSocket reattached to session ${this.sessionId}, ${this.outgoingConnections.size} active connections preserved`,
274280
);

0 commit comments

Comments
 (0)