From d9c81092013c88ff195ccbecea74880f5cebfbc3 Mon Sep 17 00:00:00 2001 From: Pascal Precht Date: Wed, 4 Mar 2020 12:21:43 +0100 Subject: [PATCH] fix(stack/proxy): ensure wsProxy and httpProxy have correct type 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. --- packages/stack/proxy/src/index.ts | 17 +++++++---------- 1 file changed, 7 insertions(+), 10 deletions(-) diff --git a/packages/stack/proxy/src/index.ts b/packages/stack/proxy/src/index.ts index cb7a18341..da422376b 100644 --- a/packages/stack/proxy/src/index.ts +++ b/packages/stack/proxy/src/index.ts @@ -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")}`); } }