From 0df700000be8bba7834ea5efe7da2bddb0acbb51 Mon Sep 17 00:00:00 2001 From: Daniel Lugo Date: Tue, 17 Nov 2020 15:27:40 -0400 Subject: [PATCH] retry and validate handshake address --- services/gunDB/contact-api/actions.js | 19 ++++++++++++++----- 1 file changed, 14 insertions(+), 5 deletions(-) diff --git a/services/gunDB/contact-api/actions.js b/services/gunDB/contact-api/actions.js index 05c8e9c7..c5dfd417 100644 --- a/services/gunDB/contact-api/actions.js +++ b/services/gunDB/contact-api/actions.js @@ -515,11 +515,20 @@ const sendHandshakeRequest = async (recipientPublicKey, gun, user, SEA) => { logger.info('sendHR() -> before currentHandshakeAddress') - const currentHandshakeAddress = await Utils.tryAndWait(gun => - gun - .user(recipientPublicKey) - .get(Key.CURRENT_HANDSHAKE_ADDRESS) - .then() + const currentHandshakeAddress = await Utils.tryAndWait( + gun => + Common.Utils.makePromise(res => { + gun + .user(recipientPublicKey) + .get(Key.CURRENT_HANDSHAKE_ADDRESS) + .once( + data => { + res(data) + }, + { wait: 1000 } + ) + }), + data => typeof data !== 'string' ) if (typeof currentHandshakeAddress !== 'string') {