Skip to content

Commit

Permalink
fix: increase default listers on abort signals (#484)
Browse files Browse the repository at this point in the history
To prevent spurious warnings appearing in the console, increase the
number of listeners on created abort signals.
  • Loading branch information
achingbrain authored Apr 9, 2024
1 parent 8c45267 commit 7cd012a
Show file tree
Hide file tree
Showing 2 changed files with 3 additions and 2 deletions.
2 changes: 1 addition & 1 deletion packages/bitswap/src/bitswap.ts
Original file line number Diff line number Diff line change
Expand Up @@ -82,8 +82,8 @@ export class Bitswap implements BitswapInterface {

async want (cid: CID, options: WantOptions = {}): Promise<Uint8Array> {
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, {
Expand Down
3 changes: 2 additions & 1 deletion packages/utils/src/utils/networked-storage.ts
Original file line number Diff line number Diff line change
@@ -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'
Expand Down Expand Up @@ -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<Required<Pick<BlockBroker, 'retrieve'>>> = []

Expand Down

0 comments on commit 7cd012a

Please sign in to comment.