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

feat: add timeout defaults #6

Merged
merged 2 commits into from
Sep 27, 2018
Merged

feat: add timeout defaults #6

merged 2 commits into from
Sep 27, 2018

Conversation

jacobheun
Copy link
Contributor

The PR aims to mitigate an issue where connections to the delegate node would stay open for an extended period. This change will pass the timeout param to the API allowing for better limiting.

  • Adds the timeout param to findProviders , which is compatible with the kad dht. This also sets a default limit of 30 seconds to limit the http calls to the delegate.

Reference: ipfs/kubo#4595 (comment)

I have verified this using the WIP libp2p implementation and a local go-ipfs delegate node.

License: MIT
Signed-off-by: Jacob Heun <jacobheun@gmail.com>
@ghost ghost assigned jacobheun Sep 24, 2018
@ghost ghost added the status/in-progress In progress label Sep 24, 2018
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.

Just left a small note here. Other than that, it seems good to me!

src/index.js Outdated
*
* @param {CID} key
* @param {number} _timeout This is ignored and is only present to comply with the dht interface
* @param {number} timeout How long the query can take. Defaults to 30 seconds
Copy link
Member

Choose a reason for hiding this comment

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

Since we are changing this, maybe we should change this param to an options object with the timeout property, and for now, keep accepting it as a number, but deprecate in the future, in favor of options.

Copy link
Contributor Author

Choose a reason for hiding this comment

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

The major reason I didn't make the change to options was to comply with how the dht is doing things, https://github.com/libp2p/js-libp2p-kad-dht/blob/0a2f9fe418d364356d27152be6a7279ebb220d2c/src/index.js#L450. I'm good making the change but we should do that in the dht as well.

Copy link
Member

Choose a reason for hiding this comment

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

You are right! I am just concerned that we may need to change all them in the future. I Can create a PR for kad-dht adding that behavior, what do you think?

License: MIT
Signed-off-by: Jacob Heun <jacobheun@gmail.com>
@jacobheun
Copy link
Contributor Author

Updated the timeout change to match the kad dht changes libp2p/js-libp2p-kad-dht#45

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

@jacobheun jacobheun merged commit 84acddc into master Sep 27, 2018
@ghost ghost removed the status/in-progress In progress label Sep 27, 2018
@jacobheun jacobheun deleted the feat/timeout-defaults branch September 27, 2018 10:21
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.

2 participants