diff --git a/packages/stack/proxy/src/index.ts b/packages/stack/proxy/src/index.ts index da422376b..610aeee97 100644 --- a/packages/stack/proxy/src/index.ts +++ b/packages/stack/proxy/src/index.ts @@ -157,14 +157,18 @@ export default class ProxyManager { this.logger.info(`WS Proxy for node endpoint ${endpoint} listening on ${buildUrl("ws", this.host, this.wsPort, "ws")}`); } } + private stopProxy() { + const promises: any[] = []; if (this.wsProxy) { - this.wsProxy.stop(); + promises.push(new Promise(resolve => this.wsProxy.stop(resolve))); this.wsProxy = null; } if (this.httpProxy) { - this.httpProxy.stop(); + promises.push(new Promise(resolve => this.httpProxy.stop(resolve))); this.httpProxy = null; } + + return promises.length ? Promise.all(promises) : Promise.resolve(); } } diff --git a/packages/stack/proxy/src/proxy.js b/packages/stack/proxy/src/proxy.js index e405534b9..cb3105042 100644 --- a/packages/stack/proxy/src/proxy.js +++ b/packages/stack/proxy/src/proxy.js @@ -343,11 +343,11 @@ export class Proxy { }); } - stop() { + stop(cb) { if (!this.server) { - return; + return cb(); } - this.server.close(); + this.server.close(cb); this.server = null; this.app = null; this.transactions = {};