diff --git a/src/handshake/index.js b/src/handshake/index.js index 3882d08..75ad78e 100644 --- a/src/handshake/index.js +++ b/src/handshake/index.js @@ -17,6 +17,9 @@ module.exports = function handshake (state) { state.cleanSecrets() if (err) { + if (err === true) { + err = new Error('Stream ended prematurely') + } state.shake.abort(err) } }) diff --git a/src/index.js b/src/index.js index afde604..db6fed6 100644 --- a/src/index.js +++ b/src/index.js @@ -25,12 +25,11 @@ module.exports = { callback = (err) => { if (err) { console.error(err) - throw err } } } - const state = new State(local, key, callback) + const state = new State(local, key, 60 * 1000 * 5, callback) pull( insecure, diff --git a/src/support.js b/src/support.js index 02ebe4f..71eba0e 100644 --- a/src/support.js +++ b/src/support.js @@ -100,7 +100,7 @@ exports.selectBest = (local, remote, cb) => { const order = Buffer.compare(oh1, oh2) 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, {