Skip to content
This repository was archived by the owner on Mar 10, 2020. It is now read-only.
This repository was archived by the owner on Mar 10, 2020. It is now read-only.

Handle errors when unpacking swarm.peers() response #885

Closed
@olizilla

Description

@olizilla

The addition of the quic protocol means there are now peers on the network with a multiaddr that cannot be unpacked by older verions of js-multiaddr, and it throws.

In the current implementation of ipfsApi.swarm.peers() we don't handle any errors that could occur when trying to wrap the peer addr from the repsonse in a Multiaddr:

https://github.com/ipfs/js-ipfs-api/blob/ead35992e9d5c60f85d74f0d80aad1b0e994ea5c/src/swarm/peers.js#L46-L51

the simplest solution would be to re-throw the error with an informative error message, but that still leaves us with the siutation when newer peers get added to the network, they can break my user-experience, as I suddenly start seeing 0 peers; js-ipfs-api throws an error if 1 peer appears invalid like in ipfs/ipfs-webui#878

A more helpful solution might be to provide some way to signal to the caller that some peers have information that we can't validate, but still do a best effort to return information about the response.

If we go the best-effort route, we've got

  1. easy - remove peers from the list if we hit an error trying to validate their info, and write a debug log. This is simple, but leaves the peer list that you get from ipfs-api containing fewer items than the http repsonse did, which is undesireable.

  2. hard - update the api response info to include peers that can't be validated. We could add a property to an idividual peer like error with the validation error, and the raw with the unvalidated response data. Or we could pull out unvalidtable peers into a sepearate list and return two arrays, could be peers (the valid ones) and rawPeers (all peers)...

Metadata

Metadata

Assignees

Labels

No labels
No labels

Type

No type

Projects

No projects

Milestone

No milestone

Relationships

None yet

Development

No branches or pull requests

Issue actions