openclaw - 💡(How to fix) Fix [Bug]: Session store lock timeout causes dropped Telegram messages [3 comments, 4 participants]

Official PRs (…)
ON THIS PAGE

Recommended Tools

×6

Utilities matched from this issue’s tags and category — try them while you read without losing context.

GitHub issue graph ai analysis

Paste a GitHub issue URL. We fetch that issue, discover linked issues from bodies/comments/timeline, collect linked pull requests, and produce a structured English report.

The report is written in English Markdown for sharing and archival.

Helpful · Quick feedback

Loading…
GitHub stats
openclaw/openclaw#49321Fetched 2026-04-08 00:56:30
View on GitHub
Comments
3
Participants
4
Timeline
3
Reactions
0
Timeline (top)
commented ×3

Error Message

  • Short follow-up messages during a long-running response are most affected
  • Lock appears to not be released properly or times out too quickly
  • Error occurred 4x within ~40 minutes (23:02, 23:05, 23:16 twice, 23:40 UTC)
  • Workaround: openclaw gateway restart clears all locks

Fix Action

Fix / Workaround

Observed behavior

  • Short follow-up messages during a long-running response are most affected
  • Lock appears to not be released properly or times out too quickly
  • Error occurred 4x within ~40 minutes (23:02, 23:05, 23:16 twice, 23:40 UTC)
  • Workaround: openclaw gateway restart clears all locks

Code Example

[telegram] handler failed: Error: timeout waiting for session store lock: /home/node/.openclaw/agents/main/sessions/sessions.json
RAW_BUFFERClick to expand / collapse

Problem

When processing longer tool chains (e.g. multiple exec/read calls), incoming Telegram messages are silently dropped with the following error:

[telegram] handler failed: Error: timeout waiting for session store lock: /home/node/.openclaw/agents/main/sessions/sessions.json

Observed behavior

  • Short follow-up messages during a long-running response are most affected
  • Lock appears to not be released properly or times out too quickly
  • Error occurred 4x within ~40 minutes (23:02, 23:05, 23:16 twice, 23:40 UTC)
  • Workaround: openclaw gateway restart clears all locks

Steps to reproduce

  1. Send a message that triggers a multi-step tool chain (several exec + read calls)
  2. While the response is being generated, send another message
  3. Second message is dropped silently (no response, no error to user)

Expected behavior

  • Incoming messages should queue and be processed after the lock is released
  • Or: lock timeout should be extended with a proper retry mechanism

Environment

  • Channel: Telegram
  • Agent: main
  • Model: anthropic/claude-sonnet-4-6

extent analysis

Fix Plan

To resolve the issue of silently dropped Telegram messages due to session store lock timeouts, we will implement a queueing system for incoming messages and extend the lock timeout with a retry mechanism.

Step-by-Step Solution

  1. Install a message queue library: Use a library like bull to handle message queueing.
  2. Implement queueing for incoming messages:
    const Queue = require('bull');
    
    // Create a queue for incoming messages
    const messageQueue = new Queue('telegramMessages');
    
    // Process incoming messages
    telegramBot.on('message', (msg) => {
      // Add message to queue
      messageQueue.add(msg);
    });
  3. Extend lock timeout and implement retry mechanism:
    // Extend lock timeout to 30 seconds
    const lockTimeout = 30000;
    
    // Implement retry mechanism with 3 attempts
    const maxAttempts = 3;
    const retryDelay = 5000; // 5 seconds
    
    // Function to acquire lock with retry
    async function acquireLockWithRetry(attempt = 0) {
      try {
        // Attempt to acquire lock
        await acquireLock();
      } catch (error) {
        if (attempt < maxAttempts) {
          // Retry after delay
          setTimeout(() => acquireLockWithRetry(attempt + 1), retryDelay);
        } else {
          // Handle max attempts reached
          console.error('Max attempts reached');
        }
      }
    }
  4. Process queued messages after lock is released:
    // Process queued messages
    messageQueue.process(async (job, done) => {
      // Acquire lock with retry
      await acquireLockWithRetry();
    
      // Process message
      try {
        // Process message logic here
        done();
      } catch (error) {
        // Handle error
        done(error);
      } finally {
        // Release lock
        releaseLock();
      }
    });

Verification

To verify the fix, send a message that triggers a multi-step tool chain and then send another message while the response is being generated. The second message should be processed after the lock is released, and no errors should be logged.

Extra Tips

  • Monitor the message queue length and adjust the queueing system as needed to prevent overload.
  • Consider implementing a dead letter queue for messages that fail processing to prevent loss of data.

Vote matrix · Quick signals

Works
Did the solution work? Tap to confirm.
Easy Fix
Was it a quick fix?
Time Saver
Did it save you time?
Blocking
Was it severely blocking?
Common Issue
Are others likely hitting this too?
Flaky / Intermittent
Is it intermittent?
Verified / Reproducible
Can you reproduce it reliably?
Loading…

FAQ

Expected behavior

  • Incoming messages should queue and be processed after the lock is released
  • Or: lock timeout should be extended with a proper retry mechanism

Still need to ship something?

×6

Another batch ranked right after the header list — different links, same matching logic.

Back to top recommendations

TRENDING