Consider it done. The open-source AI agent that works out of the box · 想到,就能做到。开源、开箱即用的 AI Agent。
TypeScript agentai-agentai-assistantandroidclaude-codecodexelectroniosllmmacosreact-nativetypescriptwindows
fix(im): recover stale Feishu WebSocket connections (#1288)
yanbabyer88c3675bde8b
diff --git a/packages/lizi-im/src/feishu/__tests__/wsClientConflict.test.ts b/packages/lizi-im/src/feishu/__tests__/wsClientConflict.test.tsindex db44737246..b192597da0 100644--- a/packages/lizi-im/src/feishu/__tests__/wsClientConflict.test.ts+++ b/packages/lizi-im/src/feishu/__tests__/wsClientConflict.test.ts@@ -11,6 +11,9 @@ interface CapturingLogger {interface MockSdkOptions {logger: CapturingLogger;domain?: string;+ wsConfig?: {+ pingTimeout?: number;+ };onReady?: () => void;onError?: (error: Error) => void;}@@ -339,6 +342,17 @@ describe('Feishu owner binding updates', () => {});describe('IM service routing', () => {+ it('enables the SDK ping watchdog for Feishu connections', async () => {+ const connecting = wsClient.start(credentials, {+ announceLifecycle: false,+ });+ const sdkClient = latestClient();++ expect(sdkClient.options.wsConfig).toEqual({ pingTimeout: 30 });+ sdkClient.options.onReady?.();+ await expect(connecting).resolves.toBe('connected');+ });+it('selects the Lark SDK domain for Lark credentials', async () => {const connecting = wsClient.start({ ...credentials, service: 'lark' },@@ -347,6 +361,7 @@ describe('IM service routing', () => {const sdkClient = latestClient();expect(sdkClient.options.domain).toBe('lark-domain');+ expect(sdkClient.options.wsConfig).toEqual({ pingTimeout: 30 });sdkClient.options.onReady?.();await expect(connecting).resolves.toBe('connected');});diff --git a/packages/lizi-im/src/feishu/wsClient.ts b/packages/lizi-im/src/feishu/wsClient.tsindex 050f7e416e..92420bc26a 100644--- a/packages/lizi-im/src/feishu/wsClient.ts+++ b/packages/lizi-im/src/feishu/wsClient.ts@@ -58,6 +58,11 @@ let pendingOfflineNotice = false;const DEFAULT_OFFLINE_ANNOUNCE_TIMEOUT_MS = 1500;export const QUIT_OFFLINE_ANNOUNCE_TIMEOUT_MS = 4500;+// The SDK disables its ping watchdog when this value is omitted. Keep the+// timeout finite so a locally OPEN but silent connection is forced through the+// existing reconnect flow instead of dropping inbound messages indefinitely.+const FEISHU_WS_PING_TIMEOUT_SECONDS = 30;+function emitRendererStatus(error?: string): void {feishuEvents.emit('status', {status: currentStatus,@@ -261,6 +266,9 @@ export async function start(domain: creds.service === 'lark' ? Lark.Domain.Lark : Lark.Domain.Feishu,loggerLevel: Lark.LoggerLevel.info,autoReconnect: true,+ wsConfig: {+ pingTimeout: FEISHU_WS_PING_TIMEOUT_SECONDS,+ },logger: makeCapturingLogger(startDetector, startedGeneration, creds.appId),onReady: () => {handleReadySignal(startDetector, startedGeneration, creds.appId);