fix(slack): deduplicate event retries across replicas - #822
izadoesdev wants to merge 3 commits into
Conversation
|
The latest updates on your projects. Learn more about Vercel for GitHub.
2 Skipped Deployments
|
|
Important Review skippedAuto reviews are disabled on this repository. Please check the settings in the CodeRabbit UI or the ⚙️ Run configurationConfiguration used: Repository UI Review profile: ASSERTIVE Plan: Advanced Run ID: You can disable this status message by setting the Use the checkbox below for a quick retry:
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 |
8e97257 to
dab1181
Compare
|
The latest updates on your projects. Learn more about Unkey Deploy
|
|
| if ( | ||
| event.subtype === "message_deleted" || | ||
| stripLeadingMention(text).trim().toLowerCase() === "stop" | ||
| ) { |
There was a problem hiding this comment.
Stop Mentions Bypass Deduplication
A normal app mention whose text is stop bypasses the cross-replica Redis claim. The production app-mention listener does not treat stop as cancellation; it routes the text into handleAgentRun after only a process-local dedupe. If Slack redelivers the event to another replica, the agent can therefore run twice. The test's synthetic stop branch does not exist in production routing.
| if ( | |
| event.subtype === "message_deleted" || | |
| stripLeadingMention(text).trim().toLowerCase() === "stop" | |
| ) { | |
| if (event.subtype === "message_deleted") { |
Slack event retries could run the agent again on another process. Claim each event atomically in the existing Redis cache before Bolt dispatches it, and retain the claim for 25 hours. Claims remain after handler failures because an action may already have happened.
Stops and message deletions bypass the claim. Other events fail closed when Redis is unavailable; explicit human mentions and plain DMs receive a retry notice. Bot messages and unrelated channel conversations stay silent, including messages identified only by a bot profile.
Validation: 74 Slack tests, root lint, all 33 typecheck tasks, and all 29 pre-push test tasks pass. Two native Bolt instances plus an isolated, nonpersistent Redis server verified duplicate suppression, stop bypass, queue cancellation, and later requests in combination with #819. Independent code review covered the rebased change and the bot-profile regression fix.
No migrations, new packages, scopes, reinstall, or account linking. Depends on #819: its production cancellation handlers must land before the stop bypass is enabled. This PR will be rebased onto that merged staging commit before final review. Deduplication limits event attempts during the cache window; it does not provide durable delivery or transaction-level exactly-once actions. No live Slack workspace was used.
Research: Slack Events API retries and event IDs, Socket Mode delivery across connections. AI-assisted implementation and review.