From a26c00e03a32644bb896df97e6ae376103ae6dde Mon Sep 17 00:00:00 2001 From: Daniel Lugo Date: Mon, 24 Feb 2020 18:29:28 -0400 Subject: [PATCH] force retry --- services/gunDB/contact-api/utils/index.js | 22 ++++++++++++---------- 1 file changed, 12 insertions(+), 10 deletions(-) diff --git a/services/gunDB/contact-api/utils/index.js b/services/gunDB/contact-api/utils/index.js index e3a16b1c..9e1683c8 100644 --- a/services/gunDB/contact-api/utils/index.js +++ b/services/gunDB/contact-api/utils/index.js @@ -159,18 +159,20 @@ const pubToEpub = async pub => { * @returns {Promise} */ const recipientPubToLastReqSentID = async recipientPub => { - const lastReqSentID = await tryAndWait(async (_, user) => { - const userToLastReqSent = user.get(Key.USER_TO_LAST_REQUEST_SENT) - const data = await userToLastReqSent.get(recipientPub).then() + const maybeLastReqSentID = await tryAndWait( + (_, user) => { + const userToLastReqSent = user.get(Key.USER_TO_LAST_REQUEST_SENT) + return userToLastReqSent.get(recipientPub).then() + }, + // retry on undefined, in case it is a false negative + v => typeof v === 'undefined' + ) - if (typeof data !== 'string') { - return null - } + if (typeof maybeLastReqSentID !== 'string') { + return null + } - return data - }) - - return lastReqSentID + return maybeLastReqSentID } /**