Skip to content

Commit

Permalink
fix(stack/proxy): have proxy.stop() receive callback
Browse files Browse the repository at this point in the history
  • Loading branch information
0x-r4bbit committed Mar 24, 2020
1 parent d9c8109 commit ec134b9
Show file tree
Hide file tree
Showing 2 changed files with 9 additions and 5 deletions.
8 changes: 6 additions & 2 deletions packages/stack/proxy/src/index.ts
Original file line number Diff line number Diff line change
Expand Up @@ -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();
}
}
6 changes: 3 additions & 3 deletions packages/stack/proxy/src/proxy.js
Original file line number Diff line number Diff line change
Expand Up @@ -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 = {};
Expand Down

0 comments on commit ec134b9

Please sign in to comment.