SocketModeClient.disconnect() takes ~5 seconds to close on 3.0.1
Los mantenedores suelen responder en 1 día
@WilliamBergamin ya está trabajando en esto.
Desde el 5/11/2026.
- #2819 de @WilliamBergamin — abierto
Evaluación
- Dificultad
- 3/5
- Tiempo estimado
- 1-2 días
- Aptitud para principiantes
- 58/100
- Tipo de issue
- Error
- Claridad
- Bien especificado
- Estado de actividad
- Activo
- Stack tecnológico
- node.js, typescript
- Área
- api, networking
Línea de trabajo
Start at SocketModeClient.disconnect() and follow the WebSocket close handling and clientPingTimeout watchdog that produce the logged delay. Run the supplied slack-shutdown.mjs reproduction with the default and shortened ping timeout. Done means disconnect() resolves promptly after SIGINT without waiting for force termination, while preserving the expected close behavior.
Escrito por el modelo de indexación a partir del texto del issue.
Descripción
Package
@slack/socket-mode
SDK Version
3.0.1
Node.js Version
v26.10.0
Operating System
MacOS 26.5.1
Steps to Reproduce
Call repro: SLACK_APP_TOKEN=xapp-... node slack-shutdown.mjs
Reproduction script
package.json
{
"name": "slack-repro",
"version": "1.0.0",
"description": "",
"main": "index.js",
"scripts": {
"test": "echo \"Error: no test specified\" && exit 1"
},
"keywords": [],
"author": "",
"license": "ISC",
"type": "module",
"dependencies": {
"@slack/socket-mode": "3.0.1"
}
}
slack-shutdown.mjs
// Repro: what a Ctrl+C actually costs when disconnecting a Slack socket-mode
// client. Connects, waits for Ctrl+C, disconnects, and stamps every step.
//
// SLACK_APP_TOKEN=xapp-… node slack-shutdown.mjs [--ping-timeout 1000]
//
// The client is built exactly like packages/channel-slack/src/connection.ts
// builds it (same options; --ping-timeout sets the SDK's clientPingTimeout,
// whose default is 5000 ms, to try other values). Install the version aivi
// pins next to this file: npm i @slack/[email protected]
//
// What the stamps say:
// - the SDK's own lines (close frame sent/received, pong watchdog) arrive
// through the routed logger, stamped with ms since start and since signal;
// - `disconnect() resolved after Xms` is what aivi's teardown awaits;
// - `event loop drained` is when the process is finally free to exit — the
// gap after `resolved` is SDK handles (timers, sockets) holding a process
// that already finished its work.
// A second Ctrl+C exits at once, like serve's.
import { SocketModeClient } from '@slack/socket-mode';
const appToken = process.env.SLACK_APP_TOKEN;
if (!appToken) {
console.error('no SLACK_APP_TOKEN in the environment');
process.exit(1);
}
const pingAt = process.argv.indexOf('--ping-timeout');
const pingTimeout = pingAt > 0 ? Number(process.argv[pingAt + 1]) : undefined;
const began = Date.now();
let signalAt = 0;
const at = () => `${String(Date.now() - began).padStart(6)}ms`;
const since = () => (signalAt ? ` (+${Date.now() - signalAt}ms from signal)` : '');
const line = level => (msg, ...rest) =>
console.log(`${at()} ${level.padEnd(5)} ${msg}${rest.length ? ` ${rest.map(String).join(' ')}` : ''}`);
// Every SDK log line, routed here with a stamp: the close handshake, the pong
// watchdog, all of it, in order, with times.
const logger = {
debug: line('debug'),
info: line('info'),
warn: line('WARN'),
error: line('ERROR'),
setLevel: () => {},
getLevel: () => 'debug',
setName: () => {},
};
const client = new SocketModeClient({
appToken,
clientOptions: { retryConfig: { retries: 0 } },
logger,
...(Number.isFinite(pingTimeout) ? { clientPingTimeout: pingTimeout } : {}),
});
const pingLabel = Number.isFinite(pingTimeout) ? `clientPingTimeout=${pingTimeout}ms` : 'clientPingTimeout=default 5000ms';
console.log(`${at()} connect: start() (${pingLabel})`);
await client.start();
console.log(`${at()} connected — press Ctrl+C`);
process.on('beforeExit', () => console.log(`${at()} event loop drained — free to exit${since()}`));
process.on('exit', () => console.log(`${at()} process exit${since()}`));
let stopping = false;
process.once('SIGINT', async () => {
if (stopping) {
console.log(`${at()} second SIGINT — process.exit(1) now`);
process.exit(1);
}
stopping = true;
signalAt = Date.now();
const readyStates = ['CONNECTING', 'OPEN', 'CLOSING', 'CLOSED'];
const state = readyStates[client.websocket?.readyState ?? -1] ?? 'absent';
console.log(`${at()} SIGINT — websocket is ${state}; calling disconnect() and awaiting it`);
const started = Date.now();
await client.disconnect();
console.log(`${at()} disconnect() resolved after ${Date.now() - started}ms${since()}`);
console.log(`${at()} our work is done; anything after this is the SDK's handles keeping the process alive`);
});
Reproduction output
Logs
0ms debug The logLevel given to WebClient was ignored as you also gave logger
1ms debug initialized
1ms debug The Socket Mode client has successfully initialized
1ms connect: start() (clientPingTimeout=default 5000ms)
1ms debug Starting Socket Mode session ...
1ms debug Going to retrieve a new WSS URL ...
1ms debug apiCall('apps.connections.open') start
2ms debug http request url: https://slack.com/api/apps.connections.open
2ms debug http request body: {}
2ms debug http request headers: {"User-Agent":"@slack:socket-mode/3.0.1 @slack:web-api/8.1.1 node/26.10.0 darwin/25.5.0","Accept":"application/json","Authorization":"[[REDACTED]]","Content-Type":"application/x-www-form-urlencoded"}
221ms debug http response received
223ms debug http request result: {"ok":true,"url":"wss://wss-primary.slack.com/link/?ticket=redacted&app_id=redacted","response_metadata":{"scopes":{"0":"connections:write"},"acceptedScopes":{"0":"connections:write"}}}
223ms debug apiCall('apps.connections.open') end
223ms debug Initiating new WebSocket connection.
480ms debug WebSocket open event received (connection established)!
480ms debug Started monitoring pings to and pongs from Slack.
489ms debug Received a message on the WebSocket: {"type":"hello","num_connections":1,"debug_info":{"host":"applink-1","build_number":27,"approximate_connection_time":18060},"connection_info":{"app_id":"redacted"}}
490ms connected — press Ctrl+C
^C 3890ms SIGINT — websocket is OPEN; calling disconnect() and awaiting it
3891ms debug Manually disconnecting this Socket Mode client
3891ms debug Sending close frame (status=1000).
10482ms WARN A pong wasn't received from the server before the timeout of 5000ms!
10483ms debug Terminating WebSocket (close frame sent but no response, force-terminating).
10483ms debug isActive(): websocket not instantiated!
10483ms disconnect() resolved after 6593ms (+6593ms from signal)
10483ms our work is done; anything after this is the SDK's handles keeping the process alive
10483ms event loop drained — free to exit (+6593ms from signal)
10483ms process exit (+6593ms from signal)
Expected Result
A disconnect.
Actual Result
A long delay, waiting for sdk's force quit. See log output in repro.
- Lenguaje dominante
- TypeScript
- Estrellas
- 3.4k
- Forks
- 693
- Merge medio
- 2 d 5 h
- PR fusionados (30 d)
- 37
Preparar el entorno
- Sin Dockerfile ni archivo de Docker Compose
- Tiene una plantilla de pull request
- Leer la guía de contribución
Primeros pasos
- Lee el issue completo y luego la guía de contribución del proyecto.
- Comenta en el issue que vas a ocuparte — evita que dos personas hagan lo mismo.
- Haz un fork del repositorio y trabaja en una rama.
- Abre un pull request que haga referencia al número del issue.
Más de slackapi/node-slack-sdk
-
ThreadBroadcastMessageEvent is missing `bot_id`Posiblemente ocupada @sean0407 la tomó hace 25 días. Abiertountriaged
Dificultad 2/5 1-3 horas Aptitud para principiantes 78/100
slackapi/node-slack-sdk#2766 ·
Los mantenedores suelen responder en 1 día
-
Support assistant.search.* APIsPosiblemente ocupada Un pull request vinculado a esta issue está abierto o ya se fusionó. Abiertoauto-triage-skip enhancement pkg:web-api
Dificultad 2/5 1-3 horas Aptitud para principiantes 68/100
slackapi/node-slack-sdk#2607 · 2 comentarios · 2 reacciones ·
Los mantenedores suelen responder en 1 día
-
`SlackListsItem FieldMessage.message` type does not match API response shapePosiblemente ocupada @AjTheSpidey la tomó hace 176 días. Abiertoarea:typescript auto-triage-skip bug pkg:web-api
Dificultad 2/5 1-3 horas Aptitud para principiantes 82/100
slackapi/node-slack-sdk#2598 · 2 comentarios ·
Los mantenedores suelen responder en 1 día
-
Missing TypeScript response type for files.uploadV2Posiblemente ocupada @dajiaohuang la tomó hace 43 días. Abiertoarea:typescript auto-triage-skip bug pkg:web-api
Dificultad 2/5 1-3 horas Aptitud para principiantes 66/100
slackapi/node-slack-sdk#2459 · 2 comentarios ·
Los mantenedores suelen responder en 1 día
-
Docs/types: document `broadcast_delete` on chat.delete (undo reply_broadcast)Posiblemente ocupada Un pull request vinculado a esta issue está abierto o ya se fusionó. Abiertoarea:typescript enhancement pkg:web-api semver:patch
Dificultad 5/5 Más de una semana Aptitud para principiantes 25/100
slackapi/node-slack-sdk#2815 · 1 comentario ·
Los mantenedores suelen responder en 1 día
Todos los issues de slackapi/node-slack-sdk
Issues similares
-
desktop v3 windows
Dificultad 2/5 1-3 horas Aptitud para principiantes 75/100
esengine/DeepSeek-Reasonix#15016 · 1 comentario ·
Los mantenedores suelen responder en 1 día
-
FR: Support CJK brackets, symbols and full-width markers in footnoteHeuristics (EBPAJ support)Abierto
Dificultad 2/5 1-3 horas Aptitud para principiantes 72/100
readest/readest#7413 · 1 comentario ·
Los mantenedores suelen responder en 1 día
-
enhancement good first issue priority: medium size: XS
Dificultad 2/5 1-3 horas Aptitud para principiantes 85/100
Los mantenedores suelen responder en 1 día
-
content triage
Dificultad 2/5 1-3 horas Aptitud para principiantes 72/100
Los mantenedores suelen responder en 1 día
-
Dificultad 2/5 1-3 horas Aptitud para principiantes 75/100
eliasstravik/herdr-projects#788 ·