From 2d053064b28a4d4a0b3bb020dc953045147e42db Mon Sep 17 00:00:00 2001 From: Ammar Date: Sat, 6 Dec 2025 15:27:38 -0600 Subject: [PATCH] =?UTF-8?q?=F0=9F=A4=96=20fix:=20remove=20duplicate=20caug?= =?UTF-8?q?ht-up=20event=20in=20onChat=20subscription?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit The onChat handler was pushing a caught-up event after replayHistory, but replayHistory already sends caught-up at the end of emitHistoricalEvents. This resulted in two caught-up events being sent to the client. Removed the duplicate push to clean up the code. --- src/node/orpc/router.ts | 7 +------ 1 file changed, 1 insertion(+), 6 deletions(-) diff --git a/src/node/orpc/router.ts b/src/node/orpc/router.ts index 3d2e1178a..46b25ad99 100644 --- a/src/node/orpc/router.ts +++ b/src/node/orpc/router.ts @@ -370,16 +370,11 @@ export const router = (authToken?: string) => { push(message); }); - // 2. Replay history + // 2. Replay history (sends caught-up at the end) await session.replayHistory(({ message }) => { push(message); }); - // 3. Signal that subscription is established and history replay is complete - // This allows clients to know when they can safely send messages without - // missing events due to async generator setup timing - push({ type: "caught-up" }); - try { yield* iterate(); } finally {