Skip to content

Commit

Permalink
Merge ea7ef2f into f48bef0
Browse files Browse the repository at this point in the history
  • Loading branch information
dadepo authored Aug 30, 2022
2 parents f48bef0 + ea7ef2f commit 73efabf
Show file tree
Hide file tree
Showing 3 changed files with 12 additions and 0 deletions.
4 changes: 4 additions & 0 deletions packages/beacon-node/src/network/reqresp/reqResp.ts
Original file line number Diff line number Diff line change
@@ -1,3 +1,4 @@
import {setMaxListeners} from "node:events";
import {Connection} from "libp2p";
import {HandlerProps} from "libp2p/src/registrar";
import LibP2p from "libp2p";
Expand Down Expand Up @@ -71,6 +72,9 @@ export class ReqResp implements IReqResp {

async start(): Promise<void> {
this.controller = new AbortController();
// We set infinity to prevent MaxListenersExceededWarning which get logged when listeners > 10
// Since it is perfectly fine to have listeners > 10
setMaxListeners(Infinity, this.controller.signal);
for (const [method, version, encoding] of protocolsSupported) {
await this.libp2p.handle(
formatProtocolId(method, version, encoding),
Expand Down
4 changes: 4 additions & 0 deletions packages/beacon-node/src/node/nodejs.ts
Original file line number Diff line number Diff line change
@@ -1,3 +1,4 @@
import {setMaxListeners} from "node:events";
import LibP2p from "libp2p";
import {Registry} from "prom-client";

Expand Down Expand Up @@ -118,6 +119,9 @@ export class BeaconNode {
metricsRegistries = [],
}: IBeaconNodeInitModules): Promise<T> {
const controller = new AbortController();
// We set infinity to prevent MaxListenersExceededWarning which get logged when listeners > 10
// Since it is perfectly fine to have listeners > 10
setMaxListeners(Infinity, controller.signal);
const signal = controller.signal;

// start db if not already started
Expand Down
4 changes: 4 additions & 0 deletions packages/validator/src/validator.ts
Original file line number Diff line number Diff line change
Expand Up @@ -121,6 +121,10 @@ export class Validator {
}

const emitter = new ValidatorEventEmitter();
// Validator event emitter can have more than 10 listeners in a normal course of operation
// We set infinity to prevent MaxListenersExceededWarning which get logged when listeners > 10
emitter.setMaxListeners(Infinity);

const chainHeaderTracker = new ChainHeaderTracker(logger, api, emitter);

this.blockProposingService = new BlockProposingService(config, loggerVc, api, clock, validatorStore, metrics, {
Expand Down

0 comments on commit 73efabf

Please sign in to comment.