feat: upgrade to @slack/web-api v8 with proxy support via undici#619
feat: upgrade to @slack/web-api v8 with proxy support via undici#619zimeg wants to merge 5 commits into
Conversation
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>
|
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 Report✅ All modified and coverable lines are covered by tests. Additional details and impacted files@@ Coverage Diff @@
## main #619 +/- ##
==========================================
- Coverage 99.86% 99.85% -0.01%
==========================================
Files 7 7
Lines 736 710 -26
==========================================
- Hits 735 709 -26
Misses 1 1 ☔ View full report in Codecov by Sentry. 🚀 New features to boost your workflow:
|
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
left a comment
There was a problem hiding this comment.
🪄 A comment about webhook implementations while we explore changes-
| const response = await this.fetchWithRetry( | ||
| config.inputs.webhook, | ||
| config.content.values, | ||
| { | ||
| ...this.proxies(config), | ||
| method: "POST", | ||
| headers: { | ||
| "Content-Type": "application/json", | ||
| "User-Agent": config.userAgent, | ||
| }, | ||
| body: JSON.stringify(config.content.values), | ||
| }, | ||
| retryConfig, | ||
| fetchFn, | ||
| ); |
There was a problem hiding this comment.
🔮 thought: At a glance this adds code that might be handled with @slack/webhook better?
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>
Summary
This pull request upgrades to
@slack/web-apiv8 release candidate (slackapi/node-slack-sdk#2603), maintaining full proxy support by migrating from axios/https-proxy-agent to nativefetchwith undiciProxyAgent.Changes:
agentWebClient option withfetchoption using undiciProxyAgentfor proxy routingaxios/axios-retrywith nativefetch+ built-in retry logic for webhook requestshttps-proxy-agentwithundiciProxyAgentfor both API method and webhook proxy supportErrorsubclasses (WebAPIPlatformError,WebAPIHTTPError, etc.)config.fetchfor testability (same pattern as the previousconfig.axios)Dependencies removed:
axios,axios-retry,https-proxy-agentDependencies added:
undici(forProxyAgent)Dependencies upgraded:
@slack/web-api^7 → ^8.0.0-rc.1,@slack/logger^4 → ^5.0.0-rc.1The
proxyinput andHTTPS_PROXYenvironment variable continue to work unchanged for end users.Requirements