From c3cde768c4d411546fc1bbfe7791c3660a432eec Mon Sep 17 00:00:00 2001 From: Nitin Patel <31539366+niinpatel@users.noreply.github.com> Date: Fri, 15 Mar 2019 14:44:24 +0530 Subject: [PATCH] fix: dht.findProvs.js handle valid hash but no providers (#950) License: MIT Signed-off-by: Nitin Patel --- src/dht/findprovs.js | 6 ++++++ 1 file changed, 6 insertions(+) diff --git a/src/dht/findprovs.js b/src/dht/findprovs.js index 8585b054c8..dd2d82f58d 100644 --- a/src/dht/findprovs.js +++ b/src/dht/findprovs.js @@ -23,6 +23,12 @@ module.exports = (send) => { } const handleResult = (res, callback) => { + // callback with an empty array if no providers are found + if (!res) { + const responses = [] + return callback(null, responses) + } + // Inconsistent return values in the browser vs node if (Array.isArray(res)) { res = res[0]