Skip to content

Telegram typing indicator keepalive loop leaks after reply completes #27493

@steubens

Description

@steubens

Description

The Telegram sendChatAction("typing") keepalive loop occasionally fails to clean up after a reply is fully dispatched. The typing indicator continues indefinitely (observed 2+ hours) despite the built-in TTL safety net (typingTtlMs = 120000).

Steps to Reproduce

  1. Have a cron job or automated session that sends a reply to a Telegram chat
  2. Reply completes and is delivered successfully
  3. The typing keepalive loop (in createTypingController) continues running indefinitely
  4. sendChatAction calls accumulate in the logs as errors (network request failures from rate limiting or intermittent connectivity)

Expected Behavior

The typing keepalive loop should stop after:

  1. The reply is dispatched (markRunComplete + markDispatchIdlecleanup())
  2. At most 2 minutes via the TTL timer (typingTtlMs)

Actual Behavior

  • The keepalive loop continues firing sendChatAction indefinitely
  • 183+ failed calls observed over a 2+ hour window
  • The TTL timer does not appear to fire, possibly because:
    • refreshTypingTtl() is being called which resets the timer
    • Or the timer is being cleared without being re-set during cleanup
    • Or cleanup() is never reached because markRunComplete and markDispatchIdle don't both get called in certain code paths (e.g., cron sessions, announce flows)

Relevant Code

// reply-*.js → createTypingController()
const cleanup = () => {
    if (sealed) return;
    typingTtlTimer && clearTimeout(typingTtlTimer);
    typingLoop.stop();
    if (active) onCleanup?.();
    resetCycle();
    sealed = true;
};

const maybeStopOnIdle = () => {
    if (!active) return;
    if (runComplete && dispatchIdle) cleanup();  // Both flags needed
};

The maybeStopOnIdle() requires BOTH runComplete AND dispatchIdle to be true. If either flag isn't set (e.g., dispatch completes but markRunComplete is never called, or vice versa), cleanup never fires and the TTL is the only safety net.

Log Evidence

error telegram/api telegram sendChatAction failed: Network request for 'sendChatAction' failed!

(Repeated every 1-10 seconds for 2+ hours until gateway restart)

Environment

  • OpenClaw v2026.2.24
  • Telegram channel
  • Config: typingMode: "message", typingIntervalSeconds: 10
  • Observed with cron job sessions that post to group topics

Workaround

Gateway restart clears all stuck loops. Setting typingMode: "never" prevents the issue entirely but loses all typing indicators.

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions