-
-
Notifications
You must be signed in to change notification settings - Fork 69.4k
Slack WebClient retry policy causes duplicate messages #1481
Copy link
Copy link
Closed
Description
Description
The Slack integration can send duplicate messages due to the default retry policy in @slack/web-api.
Root Cause
The Slack WebClient uses a default retry policy (tenRetriesInAboutThirtyMinutes) that retries failed requests up to 10 times over 30 minutes. When a request is slow but eventually succeeds, the retry can also succeed, resulting in duplicate messages appearing in Slack.
This is particularly noticeable when:
- Network latency is high
- Slack's API is slow to respond
- There are transient 5xx errors or rate limits
Evidence
Observed in production - bot responses appearing twice in Slack channels:
Affected Code
src/slack/send.ts-sendMessageSlack()creates WebClient without custom retryConfigsrc/slack/actions.ts-getClient()creates WebClient without custom retryConfig
Proposed Fix
Add a conservative retry policy to WebClient instances:
import { type RetryOptions, WebClient } from "@slack/web-api";
const CONSERVATIVE_RETRY_OPTIONS: RetryOptions = {
retries: 2,
factor: 2,
minTimeout: 500,
maxTimeout: 3000,
randomize: true,
};
const client = new WebClient(token, { retryConfig: CONSERVATIVE_RETRY_OPTIONS });This reduces retries from 10 to 2, with much shorter timeouts (max 3 seconds vs 30 minutes), preventing the scenario where both the original and retried request succeed.
Impact
- Severity: Medium - causes confusing UX but no data loss
- Frequency: Intermittent, depends on network conditions
Reactions are currently unavailable
Metadata
Metadata
Assignees
Labels
No labels
Type
Fields
Give feedbackNo fields configured for issues without a type.
