Compare commits

...

7 Commits

Author SHA1 Message Date
achingbrain
0a485d07b3 chore: release version v0.35.6 2021-12-18 07:55:27 +01:00
achingbrain
0c3ed0a4ac chore: update contributors 2021-12-18 07:55:26 +01:00
Alex Potsides
09a0f940df fix: increase the maxlisteners for timeout controllers (#1065)
We use timeout controllers to ensure we're not dialling peers forever but we can end up registering lots of listeners for the `abort` event when peers have a lot of addresses.

In node this means we see an unhelpful `MaxListenersExceededWarning` in the console warning of a potential memory leak.

Increase the max number of listeners on the signal to silence the warning.
2021-12-18 07:34:27 +01:00
Alex Potsides
a642ad2a03 chore(deps-dev): bump libp2p-floodsub from 0.27.1 to 0.28.0 (#1062)
Co-authored-by: dependabot[bot] <49699333+dependabot[bot]@users.noreply.github.com>
2021-12-15 09:30:49 +00:00
achingbrain
8ce2f08589 chore: release version v0.35.5 2021-12-15 09:28:05 +00:00
achingbrain
fe0d9828bb chore: update contributors 2021-12-15 09:28:04 +00:00
achingbrain
c8e1b08c19 chore: typo 2021-12-15 09:25:40 +00:00
4 changed files with 30 additions and 5 deletions

View File

@@ -1,3 +1,16 @@
## [0.35.6](https://github.com/libp2p/js-libp2p/compare/v0.35.5...v0.35.6) (2021-12-18)
### Bug Fixes
* increase the maxlisteners for timeout controllers ([#1065](https://github.com/libp2p/js-libp2p/issues/1065)) ([09a0f94](https://github.com/libp2p/js-libp2p/commit/09a0f940df7fdb4ece34604e85693709df5c213e))
## [0.35.5](https://github.com/libp2p/js-libp2p/compare/v0.35.4...v0.35.5) (2021-12-15)
## [0.35.4](https://github.com/libp2p/js-libp2p/compare/v0.35.3...v0.35.4) (2021-12-15)

View File

@@ -1,6 +1,6 @@
{
"name": "libp2p",
"version": "0.35.4",
"version": "0.35.6",
"description": "JavaScript implementation of libp2p, a modular peer to peer network stack",
"leadMaintainer": "Jacob Heun <jacobheun@gmail.com>",
"main": "src/index.js",
@@ -152,7 +152,7 @@
"libp2p-bootstrap": "^0.14.0",
"libp2p-delegated-content-routing": "^0.11.0",
"libp2p-delegated-peer-routing": "^0.11.1",
"libp2p-floodsub": "^0.27.0",
"libp2p-floodsub": "^0.28.0",
"libp2p-gossipsub": "^0.12.1",
"libp2p-interfaces-compliance-tests": "^2.0.1",
"libp2p-interop": "^0.5.0",

View File

@@ -9,7 +9,8 @@ const { Multiaddr } = require('multiaddr')
const { TimeoutController } = require('timeout-abort-controller')
const { AbortError } = require('abortable-iterator')
const { anySignal } = require('any-signal')
// @ts-expect-error setMaxListeners is missing from the types
const { setMaxListeners } = require('events')
const DialRequest = require('./dial-request')
const { publicAddressesFirst } = require('libp2p-utils/src/address-sort')
const getPeer = require('../get-peer')
@@ -24,7 +25,7 @@ const {
const METRICS_COMPONENT = 'dialler'
const METRICS_PENDING_DIALS = 'pending-dials'
const METRICS_PENDING_DIAL_TARGETS = 'pending-dials-targers'
const METRICS_PENDING_DIAL_TARGETS = 'pending-dial-targets'
/**
* @typedef {import('libp2p-interfaces/src/connection').Connection} Connection
@@ -253,6 +254,10 @@ class Dialer {
// Combine the timeout signal and options.signal, if provided
const timeoutController = new TimeoutController(this.timeout)
// this controller will potentially be used while dialing lots of
// peers so prevent MaxListenersExceededWarning appearing in the console
setMaxListeners && setMaxListeners(Infinity, timeoutController.signal)
const signals = [timeoutController.signal]
options.signal && signals.push(options.signal)
const signal = anySignal(signals)

View File

@@ -24,6 +24,8 @@ const {
// @ts-ignore module with no types
} = require('set-delayed-interval')
const { DHTPeerRouting } = require('./dht/dht-peer-routing')
// @ts-expect-error setMaxListeners is missing from the types
const { setMaxListeners } = require('events')
/**
* @typedef {import('peer-id')} PeerId
@@ -149,7 +151,12 @@ class PeerRouting {
}
if (options.timeout) {
options.signal = new TimeoutController(options.timeout).signal
const controller = new TimeoutController(options.timeout)
// this controller will potentially be used while dialing lots of
// peers so prevent MaxListenersExceededWarning appearing in the console
setMaxListeners && setMaxListeners(Infinity, controller.signal)
options.signal = controller.signal
}
yield * pipe(