Skip to content

feat(webhook): add opt-in retries to IncomingWebhook and WebhookTrigger#2641

Open
zimeg wants to merge 11 commits into
eden/webhook-triggerfrom
eden/webhook-retries
Open

feat(webhook): add opt-in retries to IncomingWebhook and WebhookTrigger#2641
zimeg wants to merge 11 commits into
eden/webhook-triggerfrom
eden/webhook-retries

Conversation

@zimeg

@zimeg zimeg commented Jul 2, 2026

Copy link
Copy Markdown
Member

Summary

Adds opt-in retry support to @slack/webhook, mirroring the retryConfig convention already used by @slack/web-api's WebClient. Stacked on top of #2615 (the WebhookTrigger class), so this PR is scoped to just the retry change.

  • Both IncomingWebhook and WebhookTrigger accept a new retryConfig?: RetryOptions constructor option.
  • Adds retry-policies.ts with the same named policies exported by @slack/web-apifiveRetriesInFiveMinutes, tenRetriesInAboutThirtyMinutes, rapidRetryPolicy — re-exported from the package entry point.
  • Each send() is wrapped in p-retry using the configured policy.

Default: no retries ({ retries: 0 }) when retryConfig is unset — preserves today's behavior; retries are opt-in.

Retry conditions (transient failures only, matching @slack/web-api's intent):

  • Rate limits (429) and server errors (5xx) → retry
  • Network errors with no response → retry
  • Other client errors (4xx) → abort immediately (won't succeed on retry)

retryConfig is a transport-only option and is stripped from the posted payload (like agent).

Consumed downstream by slackapi/slack-github-action#630, which passes its 0/5/10/RAPID input through to these policies.

Requirements

🤖 Generated with Claude Code

@zimeg zimeg added semver:minor enhancement M-T: A feature request for new functionality pkg:webhook applies to `@slack/webhook` labels Jul 2, 2026
@zimeg zimeg self-assigned this Jul 2, 2026
@changeset-bot

changeset-bot Bot commented Jul 2, 2026

Copy link
Copy Markdown

🦋 Changeset detected

Latest commit: 345ff5b

The changes in this PR will be included in the next version bump.

This PR includes changesets to release 1 package
Name Type
@slack/webhook Minor

Not sure what this means? Click here to learn what changesets are.

Click here if you're a maintainer who wants to add another changeset to this PR

@codecov

codecov Bot commented Jul 2, 2026

Copy link
Copy Markdown

Codecov Report

❌ Patch coverage is 90.47619% with 10 lines in your changes missing coverage. Please review.
✅ Project coverage is 89.07%. Comparing base (7968168) to head (345ff5b).
✅ All tests successful. No failed tests found.

Additional details and impacted files
@@                   Coverage Diff                    @@
##           eden/webhook-trigger    #2641      +/-   ##
========================================================
+ Coverage                 88.96%   89.07%   +0.11%     
========================================================
  Files                        64       65       +1     
  Lines                     10375    10455      +80     
  Branches                    464      472       +8     
========================================================
+ Hits                       9230     9313      +83     
+ Misses                     1123     1121       -2     
+ Partials                     22       21       -1     
Flag Coverage Δ
cli-hooks 89.07% <90.47%> (+0.11%) ⬆️
cli-test 89.07% <90.47%> (+0.11%) ⬆️
logger 89.07% <90.47%> (+0.11%) ⬆️
oauth 89.07% <90.47%> (+0.11%) ⬆️
socket-mode 89.07% <90.47%> (+0.11%) ⬆️
web-api 89.07% <90.47%> (+0.11%) ⬆️
webhook 89.07% <90.47%> (+0.11%) ⬆️

Flags with carried forward coverage won't be shown. Click here to find out more.

🚀 New features to boost your workflow:
  • 📦 JS Bundle Analysis: Save yourself from yourself by tracking and limiting bundle sizes in JS merges.

zimeg and others added 8 commits July 2, 2026 02:25
Default the payload to an empty object so send() can be called with no
arguments, POSTing an empty body. send({}) continues to work unchanged.

Co-Authored-By: Claude <svc-devxp-claude@slack-corp.com>
…webhook-retries

# Conflicts:
#	packages/webhook/src/WebhookTrigger.ts
The `= {}` default now lives in the WebhookTrigger PR; keep the @param
description unchanged here.

Co-Authored-By: Claude <svc-devxp-claude@slack-corp.com>
Use a falsy check so an empty-string URL is rejected up front rather
than failing later at request time. Adds a guard test.

Co-Authored-By: Claude <svc-devxp-claude@slack-corp.com>
Co-Authored-By: Claude <svc-devxp-claude@slack-corp.com>
Co-Authored-By: Claude <svc-devxp-claude@slack-corp.com>
@zimeg zimeg marked this pull request as ready for review July 3, 2026 19:55
@zimeg zimeg requested a review from a team as a code owner July 3, 2026 19:55

@zimeg zimeg left a comment

Copy link
Copy Markdown
Member Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

🔏 More words for the amazing reviewers.

Copy link
Copy Markdown
Member Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Comment on lines +48 to +49
"p-retry": "^4",
"retry": "^0.13.1"

Copy link
Copy Markdown
Member Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

🔍 note: These packages align with the @slack/web-api implementations:

"p-retry": "^4",
"retry": "^0.13.1"

Comment on lines +61 to +63
// Strip transport-only options so they do not leak into the posted payload.
this.defaults.agent = undefined;
this.defaults.retryConfig = undefined;

Copy link
Copy Markdown
Member Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

📝 note: The default options passed to requests isn't ideal practice IMHO but we avoid regressions with this line.

@zimeg zimeg added this to the webhook@next milestone Jul 3, 2026
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

enhancement M-T: A feature request for new functionality pkg:webhook applies to `@slack/webhook` semver:minor

Projects

None yet

Development

Successfully merging this pull request may close these issues.

1 participant