fix: Feishu duplicate message processing#649
Open
dimeng07 wants to merge 2 commits into
Open
Conversation
- Add seenMessageIds Set to FeishuChannelPlugin for message dedup
- FeishuGateway.stop() calls wsClient.close({ force: true }) to properly
terminate WebSocket and prevent ghost connections after restart
- Do not clear dedup set on stop to prevent in-flight events from bypassing
|
Someone is attempting to deploy a commit to the op7418's projects Team on Vercel. A member of the Team first needs to authorize it. |
The Lark SDK replays unprocessed historical events when the WSClient reconnects or the bridge restarts. Without age filtering, the bot would respond to messages from hours or days ago, appearing to reply to old conversations at random times (e.g. 4:50 AM). Add a 5-minute stale message filter in enqueueMessage(): messages with create_time older than 5 minutes are dropped with a log message before being enqueued or dedup-checked.
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
问题
飞书桥接存在两个严重问题:
根因分析
问题 1:重复回复(3 个独立原因)
1a. Feishu 插件无消息去重
enqueueMessage() 直接入队无检查 messageId,Lark SDK 重连时重复推送事件。
1b. WSClient 未真正关闭
Gateway.stop() 只置空引用没有调用 SDK close(),旧连接继续存活导致 restart 时双 WSClient 同时运行。
1c. bridge-manager 并发竞态
start() 没有防止并发调用,Electron auto-start + UI 手动 Start 可能同时触发。
问题 2:回复历史消息
Lark SDK 在 WSClient 重连时会重放所有未确认的历史事件,Feishu adapter 没有过期消息过滤。
修复内容
全部 590 测试通过。
🤖 Generated with Claude Code