From 105f7f54f7010d3f44b63e3f43b7a7e279ab9215 Mon Sep 17 00:00:00 2001 From: Qmstream <51881352+Qmstream@users.noreply.github.com> Date: Tue, 23 Jul 2019 21:03:09 -0300 Subject: [PATCH 1/2] fix find providers result --- src/private.js | 6 +++++- 1 file changed, 5 insertions(+), 1 deletion(-) diff --git a/src/private.js b/src/private.js index 93ee1ab0..56786631 100644 --- a/src/private.js +++ b/src/private.js @@ -563,7 +563,7 @@ module.exports = (dht) => ({ promiseToCallback(query.run(peers))(cb) }, providerTimeout)(callback))() } catch (err) { - if (err.code !== 'ETIMEDOUT' || out.length === 0) { + if (err.code !== 'ETIMEDOUT') { throw err } } finally { @@ -576,6 +576,10 @@ module.exports = (dht) => ({ out.push(peer) }) }) + + if (out.length === 0) { + throw errcode(new Error('no providers found'), 'ERR_NOT_FOUND') + } return out.toArray() }, From 688d58844e12288a65f98706d61213185091807b Mon Sep 17 00:00:00 2001 From: Qmstream <51881352+Qmstream@users.noreply.github.com> Date: Sun, 28 Jul 2019 12:50:36 -0300 Subject: [PATCH 2/2] remove white space --- src/private.js | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/src/private.js b/src/private.js index 56786631..6da70c35 100644 --- a/src/private.js +++ b/src/private.js @@ -576,7 +576,7 @@ module.exports = (dht) => ({ out.push(peer) }) }) - + if (out.length === 0) { throw errcode(new Error('no providers found'), 'ERR_NOT_FOUND') }