Skip to content

Commit

Permalink
fix(stack/proxy): ensure wsProxy and httpProxy have correct type
Browse files Browse the repository at this point in the history
Both, `httpProxy` and `wsProxy` inside `Proxymanager` have been assigned
the value of `new Proxy(...).serve()` which is an instance of `express`.

This was wrong and causes runtime errors when proxies are being stopped as
they don't have a `stop()` API.
  • Loading branch information
0x-r4bbit committed Mar 24, 2020
1 parent 7ae1761 commit d9c8109
Showing 1 changed file with 7 additions and 10 deletions.
17 changes: 7 additions & 10 deletions packages/stack/proxy/src/index.ts
Original file line number Diff line number Diff line change
Expand Up @@ -140,23 +140,20 @@ export default class ProxyManager {
isWs: false,
logger: this.logger,
plugins: this.plugins
})
.serve(
this.host,
this.rpcPort,
);
});

this.httpProxy.serve(this.host, this.rpcPort);
this.logger.info(`HTTP Proxy for node endpoint ${endpoint} listening on ${buildUrl("http", this.host, this.rpcPort, "rpc")}`);

if (this.isWs) {
this.wsProxy = await new Proxy({
events: this.events,
isWs: true,
logger: this.logger,
plugins: this.plugins
})
.serve(
this.host,
this.wsPort,
);
});

this.wsProxy.serve(this.host, this.wsPort);
this.logger.info(`WS Proxy for node endpoint ${endpoint} listening on ${buildUrl("ws", this.host, this.wsPort, "ws")}`);
}
}
Expand Down

0 comments on commit d9c8109

Please sign in to comment.