Skip to content
This repository has been archived by the owner on Aug 23, 2019. It is now read-only.

Catch bad peerid and update deps #39

Merged
merged 3 commits into from
Nov 15, 2018
Merged

Catch bad peerid and update deps #39

merged 3 commits into from
Nov 15, 2018

Conversation

jacobheun
Copy link
Contributor

Doing some stability tests on ipfs using the latest libp2p I received an error trying to get the peer id from and address. The error is below. If the circuit dialer gets an address that is lacking a peer id, it will attempt to construct the id, but does not catch errors if the id is invalid. This PR fixes that by wrapping the PeerId creation in a try catch. I've added a test verifying the issue and fix.

This also updates dependencies.

/Users/jacobheun/git/ipfs/js-libp2p-switch/node_modules/base-x/index.js:78
    if (typeof source !== 'string') throw new TypeError('Expected String')
                                    ^

TypeError: Expected String
    at decodeUnsafe (/Users/jacobheun/git/ipfs/js-libp2p-switch/node_modules/base-x/index.js:78:43)
    at Object.decode (/Users/jacobheun/git/ipfs/js-libp2p-switch/node_modules/base-x/index.js:139:20)
    at Object.fromB58String (/Users/jacobheun/git/ipfs/js-libp2p-switch/node_modules/multihashes/src/index.js:68:27)
    at Function.exports.createFromB58String (/Users/jacobheun/git/ipfs/js-libp2p-switch/node_modules/libp2p-circuit/node_modules/peer-id/src/index.js:169:24)
    at waterfall (/Users/jacobheun/git/ipfs/js-libp2p-switch/node_modules/libp2p-circuit/src/circuit/dialer.js:220:28)
    at nextTask (/Users/jacobheun/git/ipfs/js-libp2p-switch/node_modules/async/waterfall.js:16:14)
    at exports.default (/Users/jacobheun/git/ipfs/js-libp2p-switch/node_modules/async/waterfall.js:26:5)
    at _dialRelayHelper (/Users/jacobheun/git/ipfs/js-libp2p-switch/node_modules/libp2p-circuit/src/circuit/dialer.js:209:7)
    at f (/Users/jacobheun/git/ipfs/js-libp2p-switch/node_modules/once/once.js:25:25)
    at swarm.dial.once (/Users/jacobheun/git/ipfs/js-libp2p-switch/node_modules/libp2p-circuit/src/circuit/dialer.js:264:9)

License: MIT
Signed-off-by: Jacob Heun <[email protected]>
License: MIT
Signed-off-by: Jacob Heun <[email protected]>
@ghost ghost assigned jacobheun Nov 14, 2018
@ghost ghost added the in progress label Nov 14, 2018
chore: remove pre push test

License: MIT
Signed-off-by: Jacob Heun <[email protected]>
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 f17539a into master Nov 15, 2018
@ghost ghost removed the in progress label Nov 15, 2018
@jacobheun jacobheun deleted the fix/catch-bad-peerid branch November 15, 2018 18:36
Sign up for free to subscribe to this conversation on GitHub. Already have an account? Sign in.
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

2 participants