Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

fix: conn mngr min/max connection values #528

Merged
merged 1 commit into from
Jan 6, 2020

Conversation

alanshaw
Copy link
Member

@alanshaw alanshaw commented Jan 6, 2020

Fixes the case when options are passed with maxConnections and/or minConnections set to undefined:

{
  defaultOptions: {
    maxConnections: Infinity,
    minConnections: 0,
    maxData: Infinity,
    maxSentData: Infinity,
    maxReceivedData: Infinity,
    maxEventLoopDelay: Infinity,
    pollInterval: 2000,
    movingAverageInterval: 60000,
    defaultPeerValue: 1
  },
  options: {
    minPeers: 25,
    maxConnections: undefined,
    minConnections: undefined
  }
}
// These are the values this._options ends up with:
{ maxConnections: undefined, minConnections: undefined }
      1) "before all" hook in "custom config"
(node:67176) UnhandledPromiseRejectionWarning: AssertionError [ERR_ASSERTION]: Connection Manager maxConnections must be greater than minConnections
    at new ConnectionManager (node_modules/libp2p/src/connection-manager/index.js:43:5)
    at new Libp2p (node_modules/libp2p/src/index.js:92:30)
    at Object.module.exports [as libp2p] (src/core/components/libp2p.js:27:10)
    at Proxy.start (src/core/components/start.js:48:31)
    at async Daemon.start (src/cli/daemon.js:63:31)
    at async startHttpAPI (test/http-api/routes.js:29:5)
    at async Context.<anonymous> (test/http-api/routes.js:48:7)

Fixes the case when options are passed with `maxConnections` and/or `minConnections` set to `undefined`:

```console
{
  defaultOptions: {
    maxConnections: Infinity,
    minConnections: 0,
    maxData: Infinity,
    maxSentData: Infinity,
    maxReceivedData: Infinity,
    maxEventLoopDelay: Infinity,
    pollInterval: 2000,
    movingAverageInterval: 60000,
    defaultPeerValue: 1
  },
  options: {
    minPeers: 25,
    maxConnections: undefined,
    minConnections: undefined
  }
}
{ maxConnections: undefined, minConnections: undefined }
      1) "before all" hook in "custom config"
(node:67176) UnhandledPromiseRejectionWarning: AssertionError [ERR_ASSERTION]: Connection Manager maxConnections must be greater than minConnections
    at new ConnectionManager (node_modules/libp2p/src/connection-manager/index.js:43:5)
    at new Libp2p (node_modules/libp2p/src/index.js:92:30)
    at Object.module.exports [as libp2p] (src/core/components/libp2p.js:27:10)
    at Proxy.start (src/core/components/start.js:48:31)
    at async Daemon.start (src/cli/daemon.js:63:31)
    at async startHttpAPI (test/http-api/routes.js:29:5)
    at async Context.<anonymous> (test/http-api/routes.js:48:7)
```
Copy link
Member

@vasco-santos vasco-santos left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

LGTM

Copy link
Contributor

@jacobheun jacobheun left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

LGTM

@jacobheun jacobheun merged commit a1717da into refactor/async-await Jan 6, 2020
@jacobheun jacobheun deleted the fix/min-max-conn-values branch January 6, 2020 14:03
jacobheun pushed a commit that referenced this pull request Jan 24, 2020
Fixes the case when options are passed with `maxConnections` and/or `minConnections` set to `undefined`:

```console
{
  defaultOptions: {
    maxConnections: Infinity,
    minConnections: 0,
    maxData: Infinity,
    maxSentData: Infinity,
    maxReceivedData: Infinity,
    maxEventLoopDelay: Infinity,
    pollInterval: 2000,
    movingAverageInterval: 60000,
    defaultPeerValue: 1
  },
  options: {
    minPeers: 25,
    maxConnections: undefined,
    minConnections: undefined
  }
}
{ maxConnections: undefined, minConnections: undefined }
      1) "before all" hook in "custom config"
(node:67176) UnhandledPromiseRejectionWarning: AssertionError [ERR_ASSERTION]: Connection Manager maxConnections must be greater than minConnections
    at new ConnectionManager (node_modules/libp2p/src/connection-manager/index.js:43:5)
    at new Libp2p (node_modules/libp2p/src/index.js:92:30)
    at Object.module.exports [as libp2p] (src/core/components/libp2p.js:27:10)
    at Proxy.start (src/core/components/start.js:48:31)
    at async Daemon.start (src/cli/daemon.js:63:31)
    at async startHttpAPI (test/http-api/routes.js:29:5)
    at async Context.<anonymous> (test/http-api/routes.js:48:7)
```
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

3 participants