Skip to content

[Bug] Feishu/Lark plugin triggers excessive API calls in health probe (Rate Limit Risk) #27190

@chouniu666

Description

@chouniu666

Description

The Feishu plugin currently calls the /open-apis/bot/v3/info API every minute during the Gateway health check (defined in probeFeishu). For bots running long-term or across multiple accounts, this triggers unnecessary network traffic and risks hitting Feishu's API rate limits.

When the network is unstable (e.g., 504 Gateway Timeout), the probe can hang or repeatedly fail, leading to unnecessary log noise and potential performance issues for the Gateway.

Suggested Fix

Implement a dual-TTL caching mechanism in src/probe.ts:

  1. Success Cache: 24 hours (Bot info rarely changes).
  2. Error Cache: 1 minute (Prevent hammering during temporary outages but allow quick recovery).
  3. Timeout: Add a 10s timeout to the probe request to prevent hanging.

Code Reference (Tested Solution)

// Proposed logic for src/probe.ts
const PROBE_CACHE_TTL_MS = 24 * 60 * 60 * 1000;
const PROBE_ERROR_TTL_MS = 60 * 1000;
const probeCache = new Map<string, { result: any; timestamp: number }>();

export async function probeFeishu(creds?: any) {
  // 1. Check Cache
  const cacheKey = `${creds.appId}:${creds.domain}`;
  const cached = probeCache.get(cacheKey);
  if (cached) {
    const ttl = cached.result.ok ? PROBE_CACHE_TTL_MS : PROBE_ERROR_TTL_MS;
    if (Date.now() - cached.timestamp < ttl) return cached.result;
  }

  // 2. Request with Timeout
  try {
    const client = createFeishuClient(creds);
    const response = await (client as any).request({
      method: "GET",
      url: "/open-apis/bot/v3/info",
      params: {}, 
      timeout: 10000 
    });
    // ... cache and return
  } catch (err) {
    // ... cache error for 1 min
  }
}

Environment

  • OpenClaw Version: v2026.2.25
  • Plugin: Feishu/Lark

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