fix(onebot): bring an account back when shutdown stalls

If the previous OneBot session does not finish closing, the account now
comes back online instead of staying disconnected until QQ is restarted.

Fixes #509
This commit is contained in:
DrSmoothl committed 2026-10-06 00:11:44 +08:00
1 parent e0801ff9eb
commit 940b823571
11 files changed
+273 -8

No files matched your search

+17
View File
@@ -282,4 +282,21 @@ export class WebSocketServer extends EventEmitter {
setImmediate(cb);
}
}
/** Destroy clients and, when this server owns the HTTP listener, that
* listener too. An external HTTP server is left to its owner. */
destroy(): void {
for (const ws of this.clients) {
try { ws.terminate(); } catch { /* noop */ }
}
if (this._externalServer && this._upgradeHandler) {
this._externalServer.removeListener('upgrade', this._upgradeHandler);
this._upgradeHandler = null;
}
if (this._server) {
try { this._server.closeAllConnections(); } catch { /* noop */ }
try { this._server.close(() => undefined); } catch { /* noop */ }
this._server = null;
}
}
}