Skip to content

Commit fe24fe1

Browse files
committed
fix(web): drain pending stream on reconnect to avoid stale interleaving
1 parent 3c401f8 commit fe24fe1

1 file changed

Lines changed: 4 additions & 0 deletions

File tree

apps/web/src/features/workspace/workspace-sync-hooks.ts

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -352,6 +352,10 @@ export const useWorkspaceTransportSync = ({
352352
const unsubscribe = subscribeWsConnectionState(({ kind }) => {
353353
if ((kind !== "connected" && kind !== "reconnected") || !bootstrapReady) return;
354354
void resyncWorkspaceSnapshots(kind === "reconnected");
355+
// Discard any stale chunks from the old connection before attaching on reconnect.
356+
if (kind === "reconnected") {
357+
drainPendingStreamIndex(pendingStreamIndexRef.current);
358+
}
355359
// Attach terminal channel for each session so the server sends replay + live output.
356360
const currentState = stateRefLatest.current;
357361
for (const tab of currentState.tabs) {

0 commit comments

Comments
 (0)