openclaw - ✅(Solved) Fix Feishu WebSocket: No exponential backoff on reconnect [1 pull requests, 1 comments, 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#55532Fetched 2026-04-08 01:38:23
View on GitHub
Comments
1
Participants
1
Timeline
4
Reactions
0
Author
Participants
Timeline (top)
cross-referenced ×2commented ×1referenced ×1

Error Message

Log error: Cannot read properties of undefined (reading PingInterval)

Fix Action

Fixed

PR fix notes

PR #55546: fix(feishu): exponential backoff + PingInterval guard for WS reconnect

Description (problem / solution / changelog)

Summary

Fix two bugs in the Feishu WebSocket reconnect logic that cause extended outages during Feishu rate-limiting events.

Bug 1: PingInterval undefined crash

When Feishu returns system busy (error code 1000040345), the server does not send a Pong frame with PingInterval. The Lark SDK crashes with:

Cannot read properties of undefined (reading 'PingInterval')

This prevents the WebSocket from ever recovering after a transient Feishu error.

Fix: Wrap handleControlData in a try/catch that silently swallows this specific error.

Bug 2: Fixed reconnect interval amplifies rate limiting

The Lark SDK reconnects at a fixed interval (default 120s) with no backoff. During a Feishu rate-limit event, this creates a tight loop of failed reconnects that prolongs the outage indefinitely.

Fix: Added exponential backoff on non-start reconnects: 2min → 4min → 8min → 15min (capped).

How it works

Both fixes are applied as a one-time monkey-patch on the WSClient prototype at module load time in client.ts. All Feishu accounts benefit automatically — no per-account configuration needed.

Testing

  • PingInterval crash no longer appears in logs after patch
  • Reconnect backoff visible in logs as: [feishu-ws-patch] reconnect backoff: Xs (attempt N)

Issue

Fixes #55532

Changed files

  • extensions/feishu/src/client.ts (modified, +67/-0)
RAW_BUFFERClick to expand / collapse

Bug

Feishu WS returns system busy (1000040345). OpenClaw reconnects at fixed ~2min with no backoff — prolonging outage.

Log error: Cannot read properties of undefined (reading PingInterval)

Expected

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

Env

  • Node v22 / macOS / 3 Feishu accounts

extent analysis

Fix Plan

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

Step 1: Exponential Backoff

Implement a function to calculate the backoff delay:

function calculateBackoffDelay(attempt) {
  const maxDelay = 4 * 60 * 1000; // 4 minutes
  const delay = Math.min(2 ** attempt * 60 * 1000, maxDelay);
  return delay;
}

Step 2: Fix Race Condition

Check if the WS connection is closed before attempting to reconnect:

if (ws.readyState === WebSocket.CLOSED) {
  const backoffDelay = calculateBackoffDelay(reconnectAttempts);
  setTimeout(() => reconnect(), backoffDelay);
}

Step 3: Optional Health Check

Add a health check before reconnecting:

function healthCheck() {
  // Send a ping to Feishu WS and verify the response
  ws.ping();
  return new Promise((resolve, reject) => {
    ws.on('pong', () => resolve(true));
    ws.on('error', () => reject(false));
  });
}

// Before reconnecting, perform a health check
healthCheck().then((isHealthy) => {
  if (isHealthy) {
    reconnect();
  } else {
    // Handle unhealthy connection
  }
});

Step 4: Reconnect with Backoff

Modify the reconnect function to use the exponential backoff:

let reconnectAttempts = 0;
function reconnect() {
  reconnectAttempts++;
  const backoffDelay = calculateBackoffDelay(reconnectAttempts);
  setTimeout(() => {
    // Reconnect logic here
  }, backoffDelay);
}

Verification

Verify that the fix worked by checking the reconnect attempts and delays in the logs. The reconnect attempts should now have an exponential backoff delay, and the system busy error should be reduced.

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