From ec134b9307e4d89418ee95fbbb6a4a869b3efec1 Mon Sep 17 00:00:00 2001 From: Pascal Precht Date: Thu, 5 Mar 2020 14:43:59 +0100 Subject: [PATCH] fix(stack/proxy): have proxy.stop() receive callback --- packages/stack/proxy/src/index.ts | 8 ++++++-- packages/stack/proxy/src/proxy.js | 6 +++--- 2 files changed, 9 insertions(+), 5 deletions(-) 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 = {};