Merge pull request #40 from libp2p/fix/timeout

fix(handshake): improve timeout handling
This commit is contained in:
Friedel Ziegelmayer 2016-12-13 14:18:50 +01:00 committed by GitHub
commit c149bbd9ef
3 changed files with 5 additions and 3 deletions

View File

@ -17,6 +17,9 @@ module.exports = function handshake (state) {
state.cleanSecrets() state.cleanSecrets()
if (err) { if (err) {
if (err === true) {
err = new Error('Stream ended prematurely')
}
state.shake.abort(err) state.shake.abort(err)
} }
}) })

View File

@ -25,12 +25,11 @@ module.exports = {
callback = (err) => { callback = (err) => {
if (err) { if (err) {
console.error(err) console.error(err)
throw err
} }
} }
} }
const state = new State(local, key, callback) const state = new State(local, key, 60 * 1000 * 5, callback)
pull( pull(
insecure, insecure,

View File

@ -100,7 +100,7 @@ exports.selectBest = (local, remote, cb) => {
const order = Buffer.compare(oh1, oh2) const order = Buffer.compare(oh1, oh2)
if (order === 0) { if (order === 0) {
cb(new Error('you are trying to talk to yourself')) return cb(new Error('you are trying to talk to yourself'))
} }
cb(null, { cb(null, {