Skip to content

Slack WebClient retry policy causes duplicate messages #1481

@francisbrero

Description

@francisbrero

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:

Screenshot showing duplicate messages

Affected Code

  • src/slack/send.ts - sendMessageSlack() creates WebClient without custom retryConfig
  • src/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

Metadata

Metadata

Assignees

Labels

No labels
No labels

Type

No type
No fields configured for issues without a type.

Projects

No projects

Milestone

No milestone

Relationships

None yet

Development

No branches or pull requests

Issue actions