From 89d1f1bacf7ae53c6f4ea976665f3c921aab911a Mon Sep 17 00:00:00 2001 From: Daniel Lugo Date: Mon, 24 Feb 2020 18:39:38 -0400 Subject: [PATCH] retry on undefined --- .../gunDB/contact-api/jobs/onAcceptedRequests.js | 12 +++++++++--- 1 file changed, 9 insertions(+), 3 deletions(-) diff --git a/services/gunDB/contact-api/jobs/onAcceptedRequests.js b/services/gunDB/contact-api/jobs/onAcceptedRequests.js index a44b11a0..958c5401 100644 --- a/services/gunDB/contact-api/jobs/onAcceptedRequests.js +++ b/services/gunDB/contact-api/jobs/onAcceptedRequests.js @@ -104,7 +104,7 @@ const onAcceptedRequests = (user, SEA) => { throw new TypeError("typeof feedID !== 'string'") } - const feedIDExistsOnRecipientsOutgoings = await Utils.tryAndWait( + const maybeFeedOnRecipientsOutgoings = await Utils.tryAndWait( gun => new Promise(res => { gun @@ -112,11 +112,17 @@ const onAcceptedRequests = (user, SEA) => { .get(Key.OUTGOINGS) .get(feedID) .once(feed => { - res(typeof feed !== 'undefined') + res(feed) }) - }) + }), + // retry on undefined, might be a false negative + v => typeof v === 'undefined' ) + const feedIDExistsOnRecipientsOutgoings = + typeof maybeFeedOnRecipientsOutgoings === 'object' && + maybeFeedOnRecipientsOutgoings !== null + if (!feedIDExistsOnRecipientsOutgoings) { return }