← Back to PRs

#9756: fix(feishu): prevent message redelivery during long AI generation

by cszhouwei open 2026-02-05 16:50 View on GitHub →
channel: feishu stale
## Summary - Don't await `processFeishuMessage` in the event handler so SDK sends ack immediately - Prevents Feishu from redelivering messages when AI generation takes >15s ## Root Cause The Lark SDK's `WSClient.handleEventData` waits for `eventDispatcher.invoke()` to complete before sending ack to server. When AI generation takes longer than Feishu's timeout (~15s), the server assumes failure and redelivers the same message. ## Test plan - [x] Send a message to Feishu bot that triggers long AI generation - [x] Verify message is only processed once (no duplicate logs) 🤖 Generated with [Claude Code](https://claude.com/claude-code) <!-- greptile_comment --> <h2>Greptile Overview</h2> <h3>Greptile Summary</h3> This PR changes Feishu’s WebSocket event handling so `processFeishuMessage()` is fired-and-forgotten (with a `.catch`) rather than awaited, allowing the Lark SDK to send its ACK immediately and avoid Feishu/Lark message redelivery when AI generation takes longer than the provider timeout. It also broadens Feishu message handling by adding support for rich-text `post` messages (extracting plaintext from structured content), ensures sender metadata is forcibly appended in DM bodies for auth-sensitive channels, improves browser extension relay server lifecycle (persisting server state across hot reloads, de-duping concurrent initialization, and stopping relays during control-service shutdown), and adds regression tests around session-history slicing and inbound sender-meta formatting. <h3>Confidence Score: 3/5</h3> - This PR is reasonably safe to merge once the Feishu `post` media-handling bug is fixed. - Core change (not awaiting Feishu handler) is straightforward, but the new `post` message type currently flows into the media-download path, which is a concrete behavior bug. The extension-relay concurrency change looks directionally correct but should be double-checked under failure/retry scenarios. Automated tests were not run in this environment (pnpm unavailable), so confidence is reduced. - src/feishu/message.ts; src/browser/extension-relay.ts <!-- greptile_other_comments_section --> **Context used:** - Context from `dashboard` - CLAUDE.md ([source](https://app.greptile.com/review/custom-context?memory=fd949e91-5c3a-4ab5-90a1-cbe184fd6ce8)) - Context from `dashboard` - AGENTS.md ([source](https://app.greptile.com/review/custom-context?memory=0d0c8278-ef8e-4d6c-ab21-f5527e322f13)) <!-- /greptile_comment -->

Most Similar PRs