mirror of
https://github.com/fluencelabs/js-libp2p-secio
synced 2025-05-13 23:01:19 +00:00
Merge pull request #40 from libp2p/fix/timeout
fix(handshake): improve timeout handling
This commit is contained in:
commit
c149bbd9ef
@ -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)
|
||||||
}
|
}
|
||||||
})
|
})
|
||||||
|
@ -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,
|
||||||
|
@ -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, {
|
||||||
|
Loading…
x
Reference in New Issue
Block a user