Skip to content

Commit

Permalink
fix(@embark/proxy): only up event listeners on available providers
Browse files Browse the repository at this point in the history
Only the  Ganache provider has the setMaxListener
  • Loading branch information
jrainville authored and iurimatias committed Feb 18, 2020
1 parent e5b15c3 commit caae922
Showing 1 changed file with 4 additions and 2 deletions.
6 changes: 4 additions & 2 deletions packages/stack/proxy/src/proxy.js
Original file line number Diff line number Diff line change
Expand Up @@ -42,8 +42,9 @@ export class Proxy {
_createWeb3RequestManager(provider) {
const manager = new Web3RequestManager.Manager(provider);
// Up max listener because the default 10 limit is too low for all the events the proxy handles
// Warning mostly appeared in tests
manager.provider.setMaxListeners(100);
// Warning mostly appeared in tests. The warning is also only with the Ganache provider
// eslint-disable-next-line no-unused-expressions
manager.provider?.setMaxListeners?.(100);
return manager;
}

Expand All @@ -53,6 +54,7 @@ export class Proxy {
// Using net_version instead of eth_accounts, because eth_accounts can fail if EIP1102 is not approved first
await reqMgr.send({ method: 'net_version' });
} catch (e) {
this.logger.debug(e);
throw new Error(__(`Unable to connect to the blockchain endpoint`));
}
}
Expand Down

0 comments on commit caae922

Please sign in to comment.