SocketModeClient.disconnect() takes ~5 seconds to close on 3.0.1
I maintainer di solito rispondono entro 1 giorno
Nessuno ha ancora preso questa issue.
Valutazione
- Difficoltà
- 3/5
- Tempo stimato
- 1-2 giorni
- Idoneità per principianti
- 58/100
- Tipo di issue
- Bug
- Chiarezza
- Specificata chiaramente
- Stato di attività
- Attiva
- Stack tecnologico
- node.js, typescript
- Ambito
- api, networking
Direzione di ricerca
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.
Scritto dal modello di indicizzazione a partire dal testo della issue.
Descrizione
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.
- Lingua principale
- TypeScript
- Stelle
- 3.4k
- Fork
- 688
- Merge medio
- 1g 49m
- PR unite (30g)
- 15
Preparare l'ambiente
- Nessun Dockerfile né file Docker Compose
- Ha un modello di pull request
- Leggi la guida per i contributori
Come iniziare
- Leggi tutta la issue e poi la guida ai contributi del progetto.
- Commenta sulla issue per dire che te ne occupi tu — evita che due persone facciano lo stesso lavoro.
- Fai un fork del repository e lavora su un branch.
- Apri una pull request che faccia riferimento al numero della issue.
Altre issue di slackapi/node-slack-sdk
-
ThreadBroadcastMessageEvent is missing `bot_id`Forse già presa @sean0407 l’ha presa 4 giorni fa. Apertauntriaged
Difficoltà 2/5 1-3 ore Idoneità per principianti 78/100
slackapi/node-slack-sdk#2766 ·
I maintainer di solito rispondono entro 1 giorno
-
SocketModeClient crashes on Events API payloads without an inner eventForse già presa @kyungyeon-byun-imweb-me l’ha presa 16 giorni fa. Aperta
Difficoltà 2/5 1-3 ore Idoneità per principianti 84/100
slackapi/node-slack-sdk#2753 ·
I maintainer di solito rispondono entro 1 giorno
-
Support assistant.search.* APIsForse già presa Una pull request collegata a questa issue è aperta o già unita. Apertaauto-triage-skip enhancement pkg:web-api
Difficoltà 2/5 1-3 ore Idoneità per principianti 68/100
slackapi/node-slack-sdk#2607 · 2 commenti · 2 reazioni ·
I maintainer di solito rispondono entro 1 giorno
-
`SlackListsItem FieldMessage.message` type does not match API response shapeForse già presa @AjTheSpidey l’ha presa 155 giorni fa. Apertaarea:typescript auto-triage-skip bug pkg:web-api
Difficoltà 2/5 1-3 ore Idoneità per principianti 82/100
slackapi/node-slack-sdk#2598 · 2 commenti ·
I maintainer di solito rispondono entro 1 giorno
-
Missing TypeScript response type for files.uploadV2Forse già presa @dajiaohuang l’ha presa 22 giorni fa. Apertaarea:typescript auto-triage-skip bug pkg:web-api
Difficoltà 2/5 1-3 ore Idoneità per principianti 66/100
slackapi/node-slack-sdk#2459 · 2 commenti ·
I maintainer di solito rispondono entro 1 giorno
Tutte le issue di slackapi/node-slack-sdk
Issue simili
-
community first-timers-only good first issue hacktoberfest help wanted low hanging fruit up-for-grabs
Difficoltà 1/5 Meno di un'ora Idoneità per principianti 90/100
lingdojo/kana-dojo#32663 · 1 commento · 5 reazioni ·
I maintainer di solito rispondono entro 1 giorno
-
Admin: Title Separator field can't be cleared (input falls back to "|")Forse già presa @emdashbot l’ha presa oggi. Apertabot:bug bot:in-review
Difficoltà 2/5 1-3 ore Idoneità per principianti 80/100
emdash-cms/emdash#4236 · 3 commenti ·
I maintainer di solito rispondono entro 1 giorno
-
PHP workflow streaming requests buffer the full SSE responseForse già presa @Winoren l’ha presa oggi. Apertareview: medium
Difficoltà 2/5 1-3 ore Idoneità per principianti 84/100
langgenius/dify#44270 · 1 commento · 1 reazione ·
I maintainer di solito rispondono entro 1 giorno
-
area:holodeck review-finding
Difficoltà 2/5 1-3 ore Idoneità per principianti 62/100
hyperdrive-technology/holodeck#142 ·
I maintainer di solito rispondono entro 1 giorno
-
session-worker-compile.yml uses a floating oven-sh/setup-bun@v2 tag instead of the pinned SHAAperta
Difficoltà 1/5 Meno di un'ora Idoneità per principianti 90/100
code-yeongyu/senpi#3573 ·
I maintainer di solito rispondono entro 1 giorno