From 7cd012aa2ba568845d49d63a71806d20f6ac678f Mon Sep 17 00:00:00 2001 From: Alex Potsides Date: Tue, 9 Apr 2024 07:03:29 +0100 Subject: [PATCH] fix: increase default listers on abort signals (#484) To prevent spurious warnings appearing in the console, increase the number of listeners on created abort signals. --- packages/bitswap/src/bitswap.ts | 2 +- packages/utils/src/utils/networked-storage.ts | 3 ++- 2 files changed, 3 insertions(+), 2 deletions(-) diff --git a/packages/bitswap/src/bitswap.ts b/packages/bitswap/src/bitswap.ts index 0c70ed71c..5d2bf58f9 100644 --- a/packages/bitswap/src/bitswap.ts +++ b/packages/bitswap/src/bitswap.ts @@ -82,8 +82,8 @@ export class Bitswap implements BitswapInterface { async want (cid: CID, options: WantOptions = {}): Promise { const controller = new AbortController() - setMaxListeners(Infinity, controller.signal) const signal = anySignal([controller.signal, options.signal]) + setMaxListeners(Infinity, controller.signal, signal) // find providers and connect to them this.network.findAndConnect(cid, { diff --git a/packages/utils/src/utils/networked-storage.ts b/packages/utils/src/utils/networked-storage.ts index 2fd5f2417..92a79149d 100644 --- a/packages/utils/src/utils/networked-storage.ts +++ b/packages/utils/src/utils/networked-storage.ts @@ -1,4 +1,4 @@ -import { CodeError, start, stop } from '@libp2p/interface' +import { CodeError, setMaxListeners, start, stop } from '@libp2p/interface' import { anySignal } from 'any-signal' import { IdentityBlockstore } from 'blockstore-core/identity' import { TieredBlockstore } from 'blockstore-core/tiered' @@ -250,6 +250,7 @@ async function raceBlockRetrievers (cid: CID, blockBrokers: BlockBroker[], hashe const controller = new AbortController() const signal = anySignal([controller.signal, options.signal]) + setMaxListeners(Infinity, controller.signal, signal) const retrievers: Array>> = []