@slack/socket-mode@3.0.0
Major Changes
-
fc98c8c: Drop Node.js 18 support. The minimum supported Node.js version is now 20.
-
fc98c8c: Redesigned error handling to use proper
Errorsubclasses instead of plain objects with acodeproperty.Migration: Replace
if (error.code === ErrorCode.WebsocketError)withif (error instanceof SMWebsocketError).New error classes (all extend a common
SlackSocketModeErrorabstract base class, which extendsError):SMPlatformError— Slack platform returned an error eventSMWebsocketError— WebSocket connection failure (original error incause)SMNoReplyReceivedError— Timed out waiting for a reply to an acknowledgementSMSendWhileDisconnectedError— Attempted to send while not connectedSMSendWhileNotReadyError— Attempted to send before the connection was ready
Catch any socket-mode error with
if (error instanceof SlackSocketModeError).Removed factory functions (use
newwith the corresponding class instead):websocketErrorWithOriginal()→new SMWebsocketError(original)platformErrorFromEvent()→new SMPlatformError(event)noReplyReceivedError()→new SMNoReplyReceivedError()sendWhileDisconnectedError()→new SMSendWhileDisconnectedError()sendWhileNotReadyError()→new SMSendWhileNotReadyError()
The
CodedErrorinterface is deprecated — useinstanceofchecks with specific error classes instead. Theerror.codeproperty still exists for backward-compatible checks, buterror.namevalues changed from generic'Error'to descriptive class names (e.g.,'SMWebsocketError'). -
fc98c8c: Replaced the
wsWebSocket library with a spec-compliant WebSocket implementation backed byundici.undici@^7is now a peer dependency that must be installed alongside@slack/socket-mode:npm install @slack/socket-mode undici@^7
Removed options:
clientOptions.agent(thehttpAgentpassed to the underlying web-api client). Use the new top-leveldispatcheroption instead. The dispatcher handles both the WebSocket connection and HTTP API calls (unlessclientOptions.fetchis also provided, in which casedispatcheronly applies to WebSocket).
New
dispatcheroption:import { SocketModeClient } from "@slack/socket-mode"; import { ProxyAgent } from "undici"; const client = new SocketModeClient({ appToken: process.env.SLACK_APP_TOKEN, dispatcher: new ProxyAgent("http://proxy:3128"), });
For simple proxy use cases, prefer the Node.js built-in proxy support: call
http.setGlobalProxyFromEnv()at startup or setNODE_USE_ENV_PROXY=1(Node.js 24+) withHTTP_PROXY/HTTPS_PROXYenvironment variables.The
dispatcheroption accepts any object implementing theSocketModeDispatcherinterface (structurally compatible with undici'sAgent,ProxyAgent,Client, etc.).This package now depends on
@slack/web-api@^8— anyclientOptionsyou pass are subject to web-api v8 breaking changes (e.g., theagentandtlsoptions are no longer available; useclientOptions.fetchinstead).