fix(stack/proxy): have proxy.stop() receive callback

This commit is contained in:
Pascal Precht 2020-03-05 14:43:59 +01:00 committed by Pascal Precht
parent d9c8109201
commit ec134b9307
2 changed files with 9 additions and 5 deletions

View File

@ -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();
}
}

View File

@ -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 = {};