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

helia.libp2p.onDiscoveryPeer fails with Uncaught TypeError: Cannot read properties of undefined (reading 'id') #1629

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

Comments

@SgtPooki
Copy link
Member

helia.libp2p.onDiscoveryPeer((e) => console.log(e)) fails with

Uncaught TypeError: Cannot read properties of undefined (reading 'id')
    at Ed.onDiscoveryPeer (index.min.js:49:95612)
    at <anonymous>:1:14

at if (r.id.toString() === this.peerId.toString()) {

Using libp2p from https://cdn.jsdelivr.net/npm/libp2p@0.42.2/dist/index.min.js

js-libp2p/src/libp2p.ts

Lines 505 to 523 in d6c8601

onDiscoveryPeer (evt: CustomEvent<PeerInfo>): void {
const { detail: peer } = evt
if (peer.id.toString() === this.peerId.toString()) {
log.error(new Error(codes.ERR_DISCOVERED_SELF))
return
}
if (peer.multiaddrs.length > 0) {
void this.components.peerStore.addressBook.add(peer.id, peer.multiaddrs).catch(err => { log.error(err) })
}
if (peer.protocols.length > 0) {
void this.components.peerStore.protoBook.set(peer.id, peer.protocols).catch(err => { log.error(err) })
}
this.dispatchEvent(new CustomEvent<PeerInfo>('peer:discovery', { detail: peer }))
}
}

related to ipfs/helia#52

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

now that i'm looking at the source. I see that this method is not used for what I thought, and should probably have a different name. closing this.

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

No branches or pull requests

1 participant