Back to Blog
Guide

Slack Bolt JS v5 Upgrade: the markAsUncloneable Crash and Every Break We Hit

We upgraded a Socket Mode Bolt for JS app from 4.6.0 to 5.1.0 and ran it on Node 18, 20, 22 and 26. Two changes failed silently, and a fresh install crashed on Node 20 until we pinned undici 7.

Slack Green Team
October 3, 2026
November 2, 2026
5 min read
Share:
slack api
developers
bolt
javascript

TypeError: webidl.util.markAsUncloneable is not a function means undici 8 is running on a Node version older than 22.10, which lacks the worker_threads.markAsUncloneable function undici 8 calls when it loads. Fix it with npm install undici@7 or by moving to Node 22.19 or later, the floor undici 8 declares. With Bolt for JS v5 it hits a fresh install on Node 20, because npm adds undici 8 as a peer of @slack/socket-mode. We reproduced the crash on 3 October 2026 and checked the Node versions again on 2 November 2026; both runs are below.

Bolt for JS v5 (5.0.0 shipped on 15 July 2026, 5.1.0 is current) needs Node 20 or later, drops the agent and clientTls options, and makes respond() return a fetch Response instead of an axios response. On 3 October 2026 we upgraded a small Socket Mode app from @slack/bolt 4.6.0 to 5.1.0 in our own test workspace. Nothing threw an error on Node 26. The proxy agent and the respond() result broke without a word, and a fresh install on Node 20 crashed at startup.

The v4 app we started from

A Socket Mode app with one slash command. It passes an https.Agent that logs every socket it opens, and it reads the respond() result the way v4 code often does:

// app.js: a Bolt for JS Socket Mode app, written for v4
const fs = require('node:fs');
const https = require('node:https');
const { App, LogLevel } = require('@slack/bolt');
const loggingAgent = new https.Agent({ keepAlive: true });
const origCreate = loggingAgent.createConnection.bind(loggingAgent);
loggingAgent.createConnection = (opts, cb) => { console.log('custom agent opened a socket to', opts.host); return origCreate(opts, cb); };
const t = JSON.parse(fs.readFileSync(process.env.LAB_SEC + '/tokens.json', 'utf8'));

const app = new App({
  token: t.access_token,
  appToken: t.xapp,
  socketMode: true,
  logLevel: LogLevel.INFO,
  agent: loggingAgent, // v4: custom HTTP agent for Web API calls
});

app.command('/sglab1003', async ({ ack, respond, command }) => {
  await ack();
  const res = await respond(`bolt ${require('@slack/bolt/package.json').version}: got "${command.text}"`);
  console.log('respond() returned status', res.status, 'data', JSON.stringify(res.data));
});

(async () => {
  await app.start();
  console.log(`node ${process.version}, @slack/bolt ${require('@slack/bolt/package.json').version} is running`);
})();

On 4.6.0, typing /sglab1003 v4 agent test in Slack printed:

custom agent opened a socket to slack.com
custom agent opened a socket to slack.com
custom agent opened a socket to wss-primary.slack.com
node v26.8.1, @slack/bolt 4.6.0 is running
custom agent opened a socket to hooks.slack.com
respond() returned status 200 data "ok"

The agent carried the Web API calls, the Socket Mode WebSocket and the respond() POST to hooks.slack.com.

What npm install @slack/bolt@5 changed

added 2 packages, removed 17 packages, changed 7 packages, and audited 113 packages in 2s
PackageBeforeAfter
@slack/bolt4.6.05.1.0
@slack/web-api7.19.08.2.0
@slack/socket-mode2.0.73.1.0
@slack/oauth3.0.54.0.0
undici(none)8.11.2, pulled in as a peer of socket-mode

Never appear "away" on Slack again

Cloud-based. No downloads. Works 24/7 even when your laptop is off.

Two breaks with no error

We started the same file on 5.1.0 and typed the command again:

node v26.8.1, @slack/bolt 5.1.0 is running
respond() returned status 200 data undefined

The app still connected and the reply still reached Slack. Both versions posted it:

Slack DM with ephemeral replies from the test app, each marked Only visible to you: bolt 4.6.0 got "v4 test", bolt 5.1.0 got "v5 test", bolt 5.1.0 got "v5 agent test", bolt 4.6.0 got "v4 agent test", bolt 5.1.0 got "v5 fixed", bolt 5.1.0 got "node 20 undici 7"

But two things changed silently:

  • The custom agent never logged a socket. Bolt 5.1.0 accepts the agent key, ignores it, and prints no warning. If that agent was your corporate proxy, your traffic now goes direct, or fails at the firewall.
  • res.data is undefined. respond() now returns a fetch Response, which has status but no data. Read the body with await res.text() or await res.json().

The fix that worked

The v5 migration guide replaces the agent with an undici dispatcher, passed to SocketModeReceiver for the WebSocket and to clientOptions.fetch for Web API calls. Our diff:

--- app.js (v4)
+++ app.js (v5)
@@ -1,9 +1,13 @@
-// app.js: a Bolt for JS Socket Mode app, written for v4
+// app.js: the same app after the v5 fixes
 const fs = require('node:fs');
-const https = require('node:https');
-const { App, LogLevel } = require('@slack/bolt');
-const loggingAgent = new https.Agent({ keepAlive: true });
-const origCreate = loggingAgent.createConnection.bind(loggingAgent);
-loggingAgent.createConnection = (opts, cb) => { console.log('custom agent opened a socket to', opts.host); return origCreate(opts, cb); };
+const { App, SocketModeReceiver, LogLevel } = require('@slack/bolt');
+const { fetch, Agent } = require('undici');
 const t = JSON.parse(fs.readFileSync(process.env.LAB_SEC + '/tokens.json', 'utf8'));
+
+// v5: an undici dispatcher replaces the https.Agent
+const dispatcher = new Agent({
+  keepAliveTimeout: 10_000,
+  connect: { lookup: (host, opts, cb) => { console.log('dispatcher connecting to', host); require('node:dns').lookup(host, opts, cb); } },
+});
+const receiver = new SocketModeReceiver({ appToken: t.xapp, dispatcher });
 
@@ -11,6 +15,5 @@
   token: t.access_token,
-  appToken: t.xapp,
-  socketMode: true,
+  receiver,
   logLevel: LogLevel.INFO,
-  agent: loggingAgent, // v4: custom HTTP agent for Web API calls
+  clientOptions: { fetch: (url, init) => fetch(url, { ...init, dispatcher }) },
 });
@@ -20,3 +23,4 @@
   const res = await respond(`bolt ${require('@slack/bolt/package.json').version}: got "${command.text}"`);
-  console.log('respond() returned status', res.status, 'data', JSON.stringify(res.data));
+  // v5: respond() returns a fetch Response, so read the body with text()
+  console.log('respond() returned status', res.status, 'body', JSON.stringify(await res.text()));
 });

The fixed app logged the dispatcher on all three hosts again, including the respond() call:

dispatcher connecting to slack.com
dispatcher connecting to wss-primary.slack.com
node v26.8.1, @slack/bolt 5.1.0 is running
dispatcher connecting to hooks.slack.com
respond() returned status 200 body "ok"

For a plain proxy with no TLS settings, the guide's simpler route is NODE_USE_ENV_PROXY=1 HTTPS_PROXY=... node app.js or http.setGlobalProxyFromEnv(). We did not test those.

Node 20 crashed on a fresh install

Bolt v5 says Node 20 is enough. In a new folder we ran npm install @slack/bolt@5.1.0 and nothing else. npm installed the peer dependency undici at 8.11.2, whose own package.json says "node": ">=22.19.0". Starting a v5 app without the agent option on Node 20.20.2:

node_modules/undici/lib/web/cache/cachestorage.js:20
    webidl.util.markAsUncloneable(this)
                ^

TypeError: webidl.util.markAsUncloneable is not a function
    at new CacheStorage (node_modules/undici/lib/web/cache/cachestorage.js:20:17)
    at Object.<anonymous> (node_modules/undici/index.js:179:25)
    ...
    at Object.<anonymous> (node_modules/@slack/socket-mode/dist/src/SocketModeClient.js:42:18)

Node.js v20.20.2

@slack/socket-mode 3.1.0 accepts "undici": "^7.0.0 || ^8.0.0", so pin 7 on Node 20:

npm install undici@7

That installed 7.30.0, and the same app started and answered the slash command:

node v20.20.2, @slack/bolt 5.1.0 is running
respond() returned status 200 data undefined

On 2 November 2026 we checked which Node versions have the function. This script loads undici on its own, with no Bolt, so the crash is not specific to Slack:

// check.js
const { version } = require('undici/package.json');
const wt = require('node:worker_threads');
console.log(`node ${process.version}, undici ${version}, worker_threads.markAsUncloneable: ${typeof wt.markAsUncloneable}`);
try { require('undici'); console.log("require('undici') ok"); }
catch (e) { console.log(`require('undici') threw ${e.name}: ${e.message}`); }
node v20.20.2, undici 8.11.2, worker_threads.markAsUncloneable: undefined
require('undici') threw TypeError: webidl.util.markAsUncloneable is not a function
node v22.9.0, undici 8.11.2, worker_threads.markAsUncloneable: undefined
require('undici') threw TypeError: webidl.util.markAsUncloneable is not a function
node v22.10.0, undici 8.11.2, worker_threads.markAsUncloneable: function
require('undici') ok
node v20.20.2, undici 7.30.1, worker_threads.markAsUncloneable: undefined
require('undici') ok

Node 22.10.0 is the first release in our runs with the function, and undici 7 loads without it because it checks for the function first. The newest undici, 8.12.3, now fails even earlier on old Node with TypeError: Cannot read properties of undefined (reading 'bind') from lib/interceptor/decompress.js, on Node 20.20.2, 22.9.0 and 22.10.0 alike, so the same npm install undici@7 fix applies to that message too.

Every runtime we tried:

NodeundiciResult
18.20.87.30.0 or 8.11.2Crash: ReferenceError: File is not defined
20.20.28.11.2 (npm default)Crash: TypeError: webidl.util.markAsUncloneable is not a function
20.20.27.30.0Runs, slash command answered
22.23.38.11.2Runs
26.8.18.11.2Runs, slash command answered

On Node 18, npm install only warns (npm warn EBADENGINE Unsupported engine for @slack/logger, @slack/oauth, @slack/socket-mode and @slack/types) and installs anyway, so the first sign is the crash.

If you also run Bolt for Python, our Socket Mode in Python guide covers the token errors that apply to both. For the fields Slack sends with each command, see Slack slash command payload.

Always Active

Stop Jiggling Your Mouse.

Join hundreds of remote workers who never worry about their Slack status. Set it up once, stay green forever.

Related Articles

Developers

Slack Bolt Middleware: Global and Listener, Tested

Global middleware runs for every request and listener middleware for one listener. We ran both in Bolt for Python and Bolt for JavaScript on 20 November 2026 and logged what Slack did when next() was skipped: Python answered 404 and Slack sent the event again.

Slack Green Team
Developers

Slack App Configuration Token: Generate, Rotate and Revoke

An app configuration token lets a script create Slack apps from manifests. We generated one, rotated it five times and tested it again 28 hours later.

Slack Green Team
Developers

Slack App Collaborators: Add, Remove and Transfer Ownership

Collaborators are the people who can edit a Slack app. We added and removed one on 20 November 2026 as a regular member of a test workspace, recorded who can be added and what Slack asks you to do after a removal, and wrote down the hand-over path Slack documents.

Slack Green Team