fix: ack Feishu messages before async processing#77
Conversation
|
No actionable comments were generated in the recent review. 🎉 ℹ️ Recent review info⚙️ Run configurationConfiguration used: defaults Review profile: CHILL Plan: Pro Run ID: 📒 Files selected for processing (1)
📝 WalkthroughWalkthroughThe PR refactors how the Feishu gateway handles incoming WebSocket messages. Instead of awaiting message processing inline, the handler now spawns a detached background task and returns its ACK immediately. Error handling moves into the background task's catch block, which logs errors and conditionally sends a fallback retry message. ChangesWebSocket Handler Async Refactor
Estimated code review effort🎯 3 (Moderate) | ⏱️ ~20 minutes Poem
🚥 Pre-merge checks | ✅ 5✅ Passed checks (5 passed)
✏️ Tip: You can configure your own custom pre-merge checks in the settings. ✨ Finishing Touches🧪 Generate unit tests (beta)
Tip 💬 Introducing Slack Agent: The best way for teams to turn conversations into code.Slack Agent is built on CodeRabbit's deep understanding of your code, so your team can collaborate across the entire SDLC without losing context.
Built for teams:
One agent for your entire SDLC. Right inside Slack. Thanks for using CodeRabbit! It's free for OSS, and your support helps us grow. If you like it, consider giving us a shout-out. Comment |
There was a problem hiding this comment.
Code Review
This pull request updates the Feishu gateway to process messages asynchronously, ensuring that WebSocket callbacks can return an ACK promptly to avoid message re-delivery during long-running AI tasks. The feedback suggests enhancing the error logs within this background process by including messageId and chatId to improve observability and simplify troubleshooting.
| log("error", "消息处理错误", { | ||
| error: err instanceof Error ? err.message : String(err), | ||
| }) |
There was a problem hiding this comment.
Including the messageId and chatId in the error log for the background task would significantly improve observability. Since the processing is now asynchronous and decoupled from the main request-response cycle, having these identifiers in the log makes it much easier to trace which specific message caused the error without having to manually correlate timestamps.
log("error", "消息处理错误", {
error: err instanceof Error ? err.message : String(err),
messageId: ctx.messageId,
chatId: ctx.chatId,
})
Summary
im.message.receive_v1ACK from the long-running OpenCode message processing path.onMessage(ctx)in the background and keep the existing fallback error reply behavior in the async catch handler.Why
Feishu WebSocket callbacks should return quickly. Waiting for the full AI response before the handler resolves can make Feishu retry the same message event, which can produce duplicate replies for one user message.
Verification
npm run buildnpm run typecheckSummary by CodeRabbit
Performance Improvements
Bug Fixes