From fe76b4ce497895c4b5cabf2ba265365cc63ba1f5 Mon Sep 17 00:00:00 2001 From: Mark Asdoorian Date: Tue, 15 Feb 2022 18:20:05 -0500 Subject: [PATCH] fix: clean shutdown during tests --- lib/utils/nodeManager.ts | 6 ++++++ 1 file changed, 6 insertions(+) diff --git a/lib/utils/nodeManager.ts b/lib/utils/nodeManager.ts index f1bfacd..0a2d22b 100644 --- a/lib/utils/nodeManager.ts +++ b/lib/utils/nodeManager.ts @@ -52,6 +52,8 @@ export class NodeManager extends EventEmitter imple private server: Websocket.Server|undefined; // node inspection session private session = new Session(); + // websocket connections connected to the server + private connectionSockets: Websocket[] = []; // singleton instance of the manager private static instance: NodeManager|null = null; @@ -84,6 +86,8 @@ export class NodeManager extends EventEmitter imple // setup the connection handler this.server.on('connection', (clientSocket) => { + this.connectionSockets.push(clientSocket); + // send the current cached breakpoints to the client if the client reconnects this.breakpointInfoMap.forEach((breakpointInfo) => { breakpointInfo.breakpoints.forEach((breakpoint) => { @@ -406,7 +410,9 @@ export class NodeManager extends EventEmitter imple // Shuts down the debug server public async shutdown() { + this.session.disconnect(); if (this.server) { + this.connectionSockets.forEach((socket) => socket.close()); await util.promisify(this.server.close.bind(this.server)); } }