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

fix: wait for self-query to have run before running queries #457

Merged
merged 5 commits into from
May 4, 2023

Conversation

achingbrain
Copy link
Member

In order to run a query we need DHT peers. The most common way to find these is to run a self-query which happens after startup.

There's no way for the users to know when this has happened so they end up putting arbitrary waits into the code so their queries have a better chance of succeeding.

Instead just delay all queries until the self-query has run and found some peers, then continue with the queries.

In order to run a query we need DHT peers. The most common way to
find these is to run a self-query which happens after startup.

There's no way for the users to know when this has happened so they
end up putting arbitrary waits into the code so their queries have
a better chance of succeeding.

Instead just delay all queries until the self-query has run and
found some peers, then continue with the queries.
Copy link
Member

@maschad maschad left a comment

Choose a reason for hiding this comment

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

LGTM

achingbrain added a commit to libp2p/js-libp2p that referenced this pull request May 4, 2023
js-libp2p occasionally gets all peer routers to run a query for it's
own node id.

The only module that actually requires this is kad-dht in order to
insure it has peers when it runs a query and it does this anyway since
it's part of the spec.

libp2p/js-libp2p-kad-dht#457 also updates kad-dht
to pause all executed queries until the self-query has run.

Consequently this is redundant and just creates unecessary work.
@achingbrain achingbrain merged commit 9d5bdb9 into master May 4, 2023
@achingbrain achingbrain deleted the fix/wait-for-peers-before-running-queries branch May 4, 2023 14:01
github-actions bot pushed a commit that referenced this pull request May 4, 2023
## [9.1.1](v9.1.0...v9.1.1) (2023-05-04)

### Bug Fixes

* wait for self-query to have run before running queries ([#457](#457)) ([9d5bdb9](9d5bdb9))
@github-actions
Copy link

github-actions bot commented May 4, 2023

🎉 This PR is included in version 9.1.1 🎉

The release is available on:

Your semantic-release bot 📦🚀

achingbrain added a commit to libp2p/js-libp2p that referenced this pull request May 5, 2023
js-libp2p occasionally gets all peer routers to run a query for it's
own node id.

The only module that actually requires this is kad-dht in order to
insure it has peers when it runs a query and it does this anyway since
it's part of the spec.

libp2p/js-libp2p-kad-dht#457 also updates kad-dht
to pause all executed queries until the self-query has run.

Consequently this is redundant and just creates unecessary work.

Co-authored-by: Chad Nehemiah <[email protected]>
Sign up for free to subscribe to this conversation on GitHub. Already have an account? Sign in.
Labels
Projects
None yet
Development

Successfully merging this pull request may close these issues.

2 participants