openclaw - 💡(How to fix) Fix Feishu WebSocket: No exponential backoff on reconnect, causes rate limit amplification [1 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#55531Fetched 2026-04-08 01:38:24
View on GitHub
Comments
0
Participants
1
Timeline
0
Reactions
0
Author
Participants

Error Message

Error in logs:

Code Example

Cannot read properties of undefined (reading 'PingInterval')
RAW_BUFFERClick to expand / collapse

Bug Description

When Feishu WebSocket returns system busy (code 1000040345), OpenClaw reconnects at a fixed ~2min interval with no exponential backoff — creating a feedback loop that prolongs the outage.

Error in logs:

Cannot read properties of undefined (reading 'PingInterval')

Expected Behavior

  1. Exponential backoff on reconnect (1min → 2min → 4min → cap)
  2. Fix race condition on closed WebSocket access
  3. Optional: health-check Feishu API before reconnecting

Environment

  • Node v22.22.2 / macOS
  • 3 Feishu accounts (nova, vega, tester)

extent analysis

Fix Plan

To address the issue, we will implement exponential backoff for reconnecting to Feishu WebSocket and fix the race condition on closed WebSocket access.

Step-by-Step Solution:

  1. Implement Exponential Backoff:
    • Initialize the backoff delay with a minimum value (e.g., 1 minute).
    • Double the backoff delay after each reconnect attempt, up to a maximum value (e.g., 16 minutes).
  2. Fix Race Condition:
    • Check if the WebSocket is closed before attempting to access its properties.
  3. Optional Health Check:
    • Before reconnecting, perform a health check on the Feishu API to ensure it's available.

Example Code:

const WebSocket = require('ws');
const axios = require('axios');

// Exponential backoff settings
const minBackoff = 60000; // 1 minute
const maxBackoff = 960000; // 16 minutes
let backoffDelay = minBackoff;

// WebSocket connection
let ws;

// Reconnect function with exponential backoff
async function reconnect() {
  try {
    // Optional health check
    const response = await axios.get('https://example.com/feishu/healthcheck');
    if (response.status !== 200) {
      throw new Error('Feishu API is not available');
    }

    // Reconnect to WebSocket
    ws = new WebSocket('wss://example.com/feishu/ws');

    // Reset backoff delay
    backoffDelay = minBackoff;
  } catch (error) {
    console.error('Reconnect failed:', error);

    // Exponential backoff
    backoffDelay = Math.min(backoffDelay * 2, maxBackoff);
    setTimeout(reconnect, backoffDelay);
  }
}

// Handle WebSocket close event
ws.on('close', () => {
  reconnect();
});

// Handle WebSocket error event
ws.on('error', (error) => {
  console.error('WebSocket error:', error);
  reconnect();
});

// Fix race condition on closed WebSocket access
function getPingInterval() {
  if (ws && ws.readyState === WebSocket.OPEN) {
    return ws.pingInterval;
  } else {
    return null;
  }
}

Verification

To verify the fix, monitor the application logs and WebSocket connection status. The reconnect attempts should now use exponential backoff, and the race condition on closed WebSocket access should be resolved.

Extra Tips

  • Ensure the Feishu API health check endpoint is correctly configured and returns a 200 status code when the API is available.
  • Consider implementing a maximum number of reconnect attempts to prevent infinite loops.
  • Use a reliable and efficient WebSocket library to handle connection management and error handling.

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…

Still need to ship something?

×6

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

Back to top recommendations

TRENDING