Skip to content

chore: provide proxied configurations in update to "@slack/web-api@v8" and "@slack/webhook@v8" packages#619

Open
zimeg wants to merge 22 commits into
mainfrom
support-web-api-v8
Open

chore: provide proxied configurations in update to "@slack/web-api@v8" and "@slack/webhook@v8" packages#619
zimeg wants to merge 22 commits into
mainfrom
support-web-api-v8

Conversation

@zimeg

@zimeg zimeg commented Jun 1, 2026

Copy link
Copy Markdown
Member

Summary

This pull request upgrades to the @slack/web-api and @slack/webhook v8 release candidates (slackapi/node-slack-sdk#2603), maintaining full proxy support by migrating from axios/https-proxy-agent to native fetch with the undici ProxyAgent.

Changes:

  • Send API method requests with the @slack/web-api v8 WebClient, using its fetch option instead of the removed agent option
  • Send webhook requests with the @slack/webhook v8 IncomingWebhook and WebhookTrigger clients, using their fetch option and retryConfig retry policies
  • Extract a shared, side-effect-free proxiedFetch factory (src/proxies.js) that returns a custom fetch backed by an undici ProxyAgent dispatcher — injected into both the API and webhook clients so proxying stays opt-in and testable without any global dispatcher state
  • Instrument both clients through the v8 addAppMetadata exports (rc.2 restores addAppMetadata, WebhookTrigger, and retryPolicies), so the SDK sets the User-Agent internally
  • Update API error handling to use the v8 Error subclasses (WebAPIPlatformError, WebAPIHTTPError, etc.)

Dependencies removed: axios, axios-retry, https-proxy-agent
Dependencies added: undici (for ProxyAgent)
Dependencies upgraded: @slack/web-api ^7 → ^8.0.0-rc.2, @slack/webhook ^7 → ^8.0.0-rc.2, @slack/logger ^4 → ^5.0.0-rc.1

The proxy input and HTTPS_PROXY environment variable continue to work unchanged for end users.

Requirements

Migrate from axios/https-proxy-agent to native fetch with undici
ProxyAgent, supporting the @slack/web-api v8 release candidate
(slackapi/node-slack-sdk#2603).

Breaking changes addressed:
- Replace `agent` option with `fetch` option for WebClient proxy support
- Replace axios with native fetch + undici ProxyAgent for webhook requests
- Replace axios-retry with built-in retry logic for webhook requests
- Update error handling to use v8 Error subclasses

Dependencies removed: axios, axios-retry, https-proxy-agent
Dependencies added: undici (for ProxyAgent)
Dependencies upgraded: @slack/web-api ^7 → ^8.0.0-rc.1, @slack/logger ^4 → ^5.0.0-rc.1

Co-Authored-By: Claude <svc-devxp-claude@slack-corp.com>
@changeset-bot

changeset-bot Bot commented Jun 1, 2026

Copy link
Copy Markdown

🦋 Changeset detected

Latest commit: ccbeecd

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

This PR includes changesets to release 1 package
Name Type
@slack/slack-github-action Patch

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

Cast ProxyAgent to `any` to avoid type mismatch between undici's
Dispatcher and undici-types' Dispatcher in Node's fetch signature.
Initialize userAgent property to satisfy strict property checks.

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

codecov Bot commented Jun 1, 2026

Copy link
Copy Markdown

Codecov Report

✅ All modified and coverable lines are covered by tests.
✅ Project coverage is 99.86%. Comparing base (be88bdd) to head (ccbeecd).
⚠️ Report is 4 commits behind head on main.

Additional details and impacted files
@@            Coverage Diff             @@
##             main     #619      +/-   ##
==========================================
- Coverage   99.86%   99.86%   -0.01%     
==========================================
  Files           7        8       +1     
  Lines         730      725       -5     
==========================================
- Hits          729      724       -5     
  Misses          1        1              

☔ View full report in Codecov by Harness.
📢 Have feedback on the report? Share it here.

🚀 New features to boost your workflow:
  • ❄️ Test Analytics: Detect flaky tests, report on failures, and find test suite problems.
  • 📦 JS Bundle Analysis: Save yourself from yourself by tracking and limiting bundle sizes in JS merges.

Tests must explicitly configure mocks.fetch for their specific
scenario rather than relying on a hidden default response.

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

@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.

🪄 A comment about webhook implementations while we explore changes-

Comment thread src/webhook.js Outdated
Replace the manual fetch-with-retry implementation with IncomingWebhook
from @slack/webhook v8 RC. The SDK handles HTTP internally while we
inject a custom fetch wrapper for User-Agent and proxy support.

Note: @slack/webhook v8 does not export addAppMetadata, so there is no
public way to register custom app metadata in the SDK's User-Agent. We
supplement by prepending our action identity in the custom fetch wrapper.

Co-Authored-By: Claude <svc-devxp-claude@slack-corp.com>
Use @slack/webhook IncomingWebhook only for the incoming-webhook type.
Webhook triggers use a direct fetch since the SDK has no class for them
and the response shape differs (JSON vs plain text).

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

zimeg commented Jul 13, 2026

Copy link
Copy Markdown
Member Author

[DRAFT — do not submit yet] Why the undici-types override exists

@types/node pulls undici-types transitively at a version (7.18) that trails the undici we depend on directly (7.28). Their Dispatcher types are nominally distinct, so passing a ProxyAgent to globalThis.fetch failed to type check.

Ruled out the alternatives:

  • Downgrade @types/node — every version pins undici-types ≤7.18; older pins even lower. Can't reach 7.28.
  • Downgrade undici — would sacrifice runtime fixes to appease the type checker; also must be frozen forever.
  • Add undici-types as a devDep — npm can't reconcile ~7.18 (from @types/node) with ^7.28, so it installs two copies; fetch's types still resolve the nested 7.18. No effect.

overrides is the only mechanism that rewrites the transitive pin, forcing the nested undici-types to 7.28 — verified byte-identical to runtime undici@7.28's bundled types. Lets the dispatcher field type check without an any cast.

Maintenance note: the override is a literal ^7.28.0, not self-following. If a future undici major outpaces it the mismatch returns — but CI's npm run check fails loudly, so it can't regress silently.

Co-Authored-By: Claude <svc-devxp-claude@slack-corp.com>
Now that @slack/web-api 8.0.0, @slack/webhook 8.0.0, and @slack/logger
5.0.0 are stable on the latest dist-tag, drop the -rc pins and refresh
the lockfile (@slack/types also resolves to stable 3.0.0).
undici-types releases in lockstep with undici but reaches the tree via
@types/node, so it is pinned through an overrides entry. Grouping the
two keeps the runtime dep and its override bumped together in a single
PR rather than drifting across separate ones.
@zimeg zimeg deployed to staging July 14, 2026 20:31 — with GitHub Actions Active
@zimeg zimeg added this to the 3.1 milestone Jul 14, 2026
@zimeg zimeg marked this pull request as ready for review July 14, 2026 20:32
@zimeg zimeg requested a review from a team as a code owner July 14, 2026 20:32
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

dependencies Pull requests that update a dependency file semver:patch

Projects

None yet

Development

Successfully merging this pull request may close these issues.

2 participants