fix(typing): guard fireStart against post-close invocation

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.
This commit is contained in:
Ubuntu
2026-02-25 09:03:25 +00:00
committed by Nimrod Gutman
parent b3f46f0e28
commit 97eb5542e8

View File

@@ -20,6 +20,7 @@ export function createTypingCallbacks(params: {
let closed = false;
const fireStart = async () => {
if (closed) return;
try {
await params.start();
} catch (err) {