From 97eb5542e816cb76fb38f07abfb87693159ca55c Mon Sep 17 00:00:00 2001 From: Ubuntu Date: Wed, 25 Feb 2026 09:03:25 +0000 Subject: [PATCH] fix(typing): guard fireStart against post-close invocation MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit The existing `closed` flag in `createTypingCallbacks` guards `onReplyStart` but not `fireStart` itself. If a keepalive tick is already in-flight when `fireStop` sets `closed = true` and calls `keepaliveLoop.stop()`, the running `onTick → fireStart` callback still completes and sends a stale `sendChatAction('typing')` after the reply message has been delivered. On Telegram (which has no cancel-typing API), this causes the typing indicator to linger ~5 seconds after the bot's message appears. Add a `closed` early-return in `fireStart` as defense-in-depth so that even an in-flight tick is suppressed once cleanup has started. --- src/channels/typing.ts | 1 + 1 file changed, 1 insertion(+) diff --git a/src/channels/typing.ts b/src/channels/typing.ts index 531c2fdc4..a7e5c4a35 100644 --- a/src/channels/typing.ts +++ b/src/channels/typing.ts @@ -20,6 +20,7 @@ export function createTypingCallbacks(params: { let closed = false; const fireStart = async () => { + if (closed) return; try { await params.start(); } catch (err) {