mirror of
https://github.com/moltbot/moltbot.git
synced 2026-03-08 06:54:24 +00:00
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:
@@ -20,6 +20,7 @@ export function createTypingCallbacks(params: {
|
||||
let closed = false;
|
||||
|
||||
const fireStart = async () => {
|
||||
if (closed) return;
|
||||
try {
|
||||
await params.start();
|
||||
} catch (err) {
|
||||
|
||||
Reference in New Issue
Block a user