Skip to content
This repository has been archived by the owner on Jul 21, 2023. It is now read-only.

Commit

Permalink
fix: catch errors from setMaxListeners (#275)
Browse files Browse the repository at this point in the history
Fails in electron-renderer
  • Loading branch information
achingbrain authored Dec 31, 2021
1 parent 5e5e04e commit de2c601
Show file tree
Hide file tree
Showing 2 changed files with 4 additions and 2 deletions.
4 changes: 3 additions & 1 deletion src/query-self.js
Original file line number Diff line number Diff line change
Expand Up @@ -71,7 +71,9 @@ class QuerySelf extends EventEmitter {
this._controller = new AbortController()
const signal = anySignal([this._controller.signal, timeoutController.signal])
// this controller will get used for lots of dial attempts so make sure we don't cause warnings to be logged
setMaxListeners && setMaxListeners(Infinity, signal)
try {
setMaxListeners && setMaxListeners(Infinity, signal)
} catch {} // fails on node < 15.4
const found = await length(await take(this._peerRouting.getClosestPeers(this._peerId.toBytes(), {
signal
}), this._count))
Expand Down
2 changes: 1 addition & 1 deletion src/query/manager.js
Original file line number Diff line number Diff line change
Expand Up @@ -104,7 +104,7 @@ class QueryManager {
// so make sure we don't make a lot of noise in the logs
try {
setMaxListeners && setMaxListeners(0, signal)
} catch {} // fails on node < 15
} catch {} // fails on node < 15.4

const log = logger(`libp2p:kad-dht:${this._lan ? 'lan' : 'wan'}:query:` + uint8ArrayToString(key, 'base58btc'))

Expand Down

0 comments on commit de2c601

Please sign in to comment.