fix(@embark/proxy): fix conflict for WS port in the proxy

This error arose when using tests parallel to Embark
This commit is contained in:
Jonathan Rainville 2019-11-26 14:17:04 -05:00 committed by Iuri Matias
parent db0e45e96e
commit eae97dee4f
2 changed files with 5 additions and 4 deletions

View File

@ -8,7 +8,7 @@ export function findNextPort(port: number) {
return new Promise<number>((resolve) => {
server.once("close", () => resolve(port));
server.on("error", () => resolve(findNextPort(port + 1)));
server.listen(port, () => server.close());
server.listen(port, 'localhost', () => server.close());
});
}

View File

@ -93,9 +93,10 @@ export default class ProxyManager {
this.inited = true;
// setup ports
const port = await findNextPort(this.embark.config.blockchainConfig.rpcPort + constants.blockchain.servicePortOnProxy);
this.rpcPort = port;
this.wsPort = port + 1;
const rpcPort = await findNextPort(this.embark.config.blockchainConfig.rpcPort + constants.blockchain.servicePortOnProxy);
const wsPort = await findNextPort(this.embark.config.blockchainConfig.wsPort + constants.blockchain.servicePortOnProxy);
this.rpcPort = rpcPort;
this.wsPort = wsPort;
// setup proxy details
this.isVm = this.embark.config.blockchainConfig.client === constants.blockchain.vm;