diff --git a/src/private.js b/src/private.js index 93ee1ab0..6da70c35 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 { @@ -577,6 +577,10 @@ module.exports = (dht) => ({ }) }) + if (out.length === 0) { + throw errcode(new Error('no providers found'), 'ERR_NOT_FOUND') + } + return out.toArray() },