Skip to content

Commit 9f7c682

Browse files
emizzleiurimatias
authored andcommitted
fix(@embark/proxy): Parse rpcPort from config as integer
## User reported error i recently updated to embark 5.0 im having issues connecting to a local node each time i connect to it i get the following output from the embark console ``` Error during proxy setup: Port should be >= 0 and < 65536. Received 754510.. Use '--loglevel debug' for more detailed information. ``` This is what i have under the blockchain.js file ``` localDev: { endpoint: "http://127.0.0.1:7545", accounts: [{ nodeAccounts: true, }] } ``` ### Problem The port to start the proxy on is incremented by a constant value (using the `+` operator), however the port comes from the config and in the case where it is a string, the `+` operator acts as a string concatentation. ### Fix Ensure the port from the config is always parsed to a number before attempting to add the constant proxy port offset.
1 parent 99d629c commit 9f7c682

File tree

1 file changed

+9
-4
lines changed

1 file changed

+9
-4
lines changed

packages/stack/proxy/src/index.ts

Lines changed: 9 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -92,10 +92,15 @@ export default class ProxyManager {
9292
return;
9393
}
9494
this.inited = true;
95-
96-
let port = this.embark.config.blockchainConfig.rpcPort;
97-
if (!port && port !== 0) {
98-
port = 8545;
95+
const rpcConfigPort = this.embark.config.blockchainConfig.rpcPort;
96+
let port: number = 0;
97+
try {
98+
port = typeof rpcConfigPort === "string" ? parseInt(rpcConfigPort, 10) : rpcConfigPort;
99+
if (!port && port !== 0) {
100+
port = 8545;
101+
}
102+
} catch (err) {
103+
this.logger.error(`Blockchain config 'rpcPort' contains an invalid value: '${rpcConfigPort}'`);
99104
}
100105

101106
// setup ports

0 commit comments

Comments
 (0)