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

bug: heliaInstance.libp2p.addEventListener('peer:discovery', cb) calls cb twice for same peer #1630

Closed
SgtPooki opened this issue Mar 16, 2023 · 1 comment · Fixed by #1693
Labels
need/triage Needs initial labeling and prioritization

Comments

@SgtPooki
Copy link
Member

SgtPooki commented Mar 16, 2023

Using libp2p 0.42.2 via https://cdn.jsdelivr.net/npm/[email protected]/dist/index.min.js

Peer discovery should only emit once, unless we are in fact discovering the peer twice via different methods somehow.

Either way, once a peer is discovered, we should cancel any in-progress operations and emit that we discovered the peer only once.

While working on a new helia-script-tag example (via #43), I was able to get the following event log:

1263ms - Created LibP2P instance
1263ms - Created Helia instance
2248ms - Discovered peer QmNnooDu7bfjPFoTZYxMNLWUQJyrVwtbZg5gBMjTezGAJN
2252ms - Discovered peer QmNnooDu7bfjPFoTZYxMNLWUQJyrVwtbZg5gBMjTezGAJN
2252ms - Discovered peer QmQCU2EcMqAqQPR2i9bChDtGNJchTbq5TbXJJ16u19uLTa
2252ms - Discovered peer QmQCU2EcMqAqQPR2i9bChDtGNJchTbq5TbXJJ16u19uLTa
2253ms - Discovered peer QmbLHAnMoJPWSCR5Zhtx6BHJX9KiKNN6tpvbUcqanj75Nb
2254ms - Discovered peer QmbLHAnMoJPWSCR5Zhtx6BHJX9KiKNN6tpvbUcqanj75Nb
2254ms - Discovered peer QmcZf59bWwK5XFi76CZX8cbJ4BhTzzA3gU1ZjYZcYW3dwt
2254ms - Discovered peer QmcZf59bWwK5XFi76CZX8cbJ4BhTzzA3gU1ZjYZcYW3dwt
74326ms - Connected to QmbLHAnMoJPWSCR5Zhtx6BHJX9KiKNN6tpvbUcqanj75Nb
77805ms - Connected to QmcZf59bWwK5XFi76CZX8cbJ4BhTzzA3gU1ZjYZcYW3dwt
135298ms - Disconnected from QmbLHAnMoJPWSCR5Zhtx6BHJX9KiKNN6tpvbUcqanj75Nb
138782ms - Disconnected from QmcZf59bWwK5XFi76CZX8cbJ4BhTzzA3gU1ZjYZcYW3dwt

replaces ipfs/helia#56

@SgtPooki SgtPooki added the need/triage Needs initial labeling and prioritization label Mar 16, 2023
@SgtPooki
Copy link
Member Author

You can see this in action at https://codesandbox.io/p/sandbox/helia-script-tag-g420c3, with PR to helia-examples repo at ipfs-examples/helia-examples#13

achingbrain added a commit that referenced this issue Apr 25, 2023
Adds an event emitter as a libp2p component that will echo every emitted event on the main libp2p object.

Closes #1574
Fixes  #1630
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
need/triage Needs initial labeling and prioritization
Projects
None yet
Development

Successfully merging a pull request may close this issue.

1 participant