Skip to content
This repository was archived by the owner on Jul 21, 2023. It is now read-only.

fix _findNProvidersAsync discarding search results #137

Merged
merged 2 commits into from
Jul 29, 2019
Merged
Changes from 1 commit
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
6 changes: 5 additions & 1 deletion src/private.js
Original file line number Diff line number Diff line change
Expand Up @@ -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 {
Expand All @@ -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()
},
Expand Down