Docs: migration guides for new package versions#2606
Docs: migration guides for new package versions#2606lukegalbraithrussell wants to merge 7 commits into
Conversation
|
Codecov Report✅ All modified and coverable lines are covered by tests. Additional details and impacted files@@ Coverage Diff @@
## main #2606 +/- ##
==========================================
+ Coverage 87.50% 88.86% +1.35%
==========================================
Files 62 62
Lines 10230 10230
Branches 418 450 +32
==========================================
+ Hits 8952 9091 +139
+ Misses 1256 1117 -139
Partials 22 22
Flags with carried forward coverage won't be shown. Click here to find out more. 🚀 New features to boost your workflow:
|
WilliamBergamin
left a comment
There was a problem hiding this comment.
Nice work 🥇 left a few comments mainly about remove some stuff 🙏
Maybe we should merge this branch in the v8 instead of main that was we can merge everything at the same time 🤔 at the same time there might be a delay between merging and releasing
| sidebar_label: Migrating to v2 | ||
| --- | ||
|
|
||
| # Migrating the `socket‐mode` package from v1 sto v2 |
There was a problem hiding this comment.
| # Migrating the `socket‐mode` package from v1 sto v2 | |
| # Migrating the `socket‐mode` package from v1 to v2 |
|
|
||
| This major release switches from the [`ws`](https://www.npmjs.com/package/ws) library to the [`undici`](https://undici.nodejs.org/) library's [WebSocket](https://developer.mozilla.org/en-US/docs/Web/API/WebSocket) implementation. | ||
|
|
||
| If you're not using a proxy or custom TLS, no action is needed beyond bumping the version number. |
There was a problem hiding this comment.
I'm not sure if there might be other complications needed in the transition specifically around typescript and testing 😅
| If you're not using a proxy or custom TLS, no action is needed beyond bumping the version number. | |
| If you're not using a proxy or custom TLS, we hope no action is needed beyond bumping the version number. |
|
|
||
| The main thing you'll notice: `httpAgent` is gone. You'll use a `dispatcher` option instead, which handles both WebSocket connections and HTTP API calls in one place. Or, if you're on a recent Node.js version, you can set an environment variable and skip manual proxy config entirely. | ||
|
|
||
| The `undici` library is a **peer dependency**. |
There was a problem hiding this comment.
Maybe we should remove this from the official docs 🤔 I want to try keeping it a peer dependency but if its an issue, we will make it a dependency 😅
| ##### Option A: use environment variable | ||
|
|
||
| ```bash | ||
| NODE_USE_ENV_PROXY=1 HTTPS_PROXY=http://corporate.proxy:8080 node app.js | ||
| ``` | ||
|
|
||
| ```typescript | ||
| import { SocketModeClient } from '@slack/socket-mode'; | ||
|
|
||
| // No proxy configuration needed — both WebSocket and HTTP use the proxy | ||
| const client = new SocketModeClient({ | ||
| appToken: process.env.SLACK_APP_TOKEN, | ||
| }); | ||
| ``` | ||
|
|
||
| ##### Option B: programmatically call once at startup |
There was a problem hiding this comment.
Could we swap the order to of the options 🙏 I find option B to be more more explicit
| }); | ||
| ``` | ||
|
|
||
| No separate proxy setup needed as one dispatcher covers everything. |
There was a problem hiding this comment.
I don't think we need this line 🙏
|
|
||
| ### We've overhauled error handling | ||
|
|
||
| Errors are now proper `Error` subclasses instead of interfaces with factory functions ([#2593](https://github.com/slackapi/node-slack-sdk/pull/2593)). This means `instanceof` checks work, TypeScript narrows types correctly, and error names are descriptive. |
There was a problem hiding this comment.
| Errors are now proper `Error` subclasses instead of interfaces with factory functions ([#2593](https://github.com/slackapi/node-slack-sdk/pull/2593)). This means `instanceof` checks work, TypeScript narrows types correctly, and error names are descriptive. | |
| Errors are now proper `Error` subclasses instead of interfaces. This means `instanceof` checks work, TypeScript narrows types correctly, and error names are descriptive. |
| #### New error class hierarchy | ||
|
|
||
| ``` | ||
| SlackError (abstract) | ||
| ├── WebAPIPlatformError — Slack API returned ok: false | ||
| ├── WebAPIHTTPError — non-200 HTTP status | ||
| ├── WebAPIRequestError — network/fetch failure | ||
| ├── WebAPIRateLimitedError — 429 rate limited | ||
| └── WebAPIFileUploadReadFileDataError — file read failure during upload | ||
| ``` |
There was a problem hiding this comment.
I don't think we need this section 🤔
| #### New error class hierarchy | |
| ``` | |
| SlackError (abstract) | |
| ├── WebAPIPlatformError — Slack API returned ok: false | |
| ├── WebAPIHTTPError — non-200 HTTP status | |
| ├── WebAPIRequestError — network/fetch failure | |
| ├── WebAPIRateLimitedError — 429 rate limited | |
| └── WebAPIFileUploadReadFileDataError — file read failure during upload | |
| ``` |
| ### We've added exported `fetch` types | ||
|
|
||
| You can now use these new types for implementing custom fetch functions with full TypeScript support: | ||
|
|
||
| - `FetchFunction` — the function signature | ||
| - `FetchResponse` — response interface | ||
| - `FetchRequestInit` — request options interface | ||
| - `FetchHeaders` — headers interface No newline at end of file |
There was a problem hiding this comment.
Not sure we need to call this out here 🤔
| **Option A — environment variable:** | ||
|
|
||
| ```bash | ||
| NODE_USE_ENV_PROXY=1 HTTPS_PROXY=http://corporate.proxy:8080 node app.js | ||
| ``` | ||
|
|
||
| ```typescript | ||
| import { IncomingWebhook } from '@slack/webhook'; | ||
|
|
||
| // No proxy configuration needed — globalThis.fetch respects the environment | ||
| const webhook = new IncomingWebhook(webhookUrl); | ||
| ``` | ||
|
|
||
| **Option B — programmatic (call once at startup):** |
There was a problem hiding this comment.
Here also swapping the option order 🙏
|
|
||
| This major release drops the [axios](https://www.npmjs.com/package/axios) library and uses the native [Fetch API](https://developer.mozilla.org/en-US/docs/Web/API/Fetch_API) (`globalThis.fetch`) instead. | ||
|
|
||
| The `agent` option is replaced by a `fetch` option. Pass in your own fetch function to configure proxies or TLS. If you're not using proxies or custom agents, no action is needed beyond bumping the version number. |
There was a problem hiding this comment.
| The `agent` option is replaced by a `fetch` option. Pass in your own fetch function to configure proxies or TLS. If you're not using proxies or custom agents, no action is needed beyond bumping the version number. | |
| The `agent` option is replaced by a `fetch` option. Pass in your own fetch function to configure proxies or TLS. If you're not using proxies or custom agents, we hope no action is needed beyond bumping the version number. |
Summary
previews:
Requirements