retry on undefined
This commit is contained in:
parent
0488e322b6
commit
466f12de16
1 changed files with 9 additions and 4 deletions
|
|
@ -518,8 +518,8 @@ const sendHandshakeRequest = async (recipientPublicKey, gun, user, SEA) => {
|
||||||
const lastRequestIDSentToUser = maybeLastRequestIDSentToUser
|
const lastRequestIDSentToUser = maybeLastRequestIDSentToUser
|
||||||
|
|
||||||
console.log('sendHR() -> before alreadyContactedOnCurrHandshakeNode')
|
console.log('sendHR() -> before alreadyContactedOnCurrHandshakeNode')
|
||||||
/** @type {boolean} */
|
|
||||||
const alreadyContactedOnCurrHandshakeNode = await Utils.tryAndWait(
|
const hrInHandshakeNode = await Utils.tryAndWait(
|
||||||
gun =>
|
gun =>
|
||||||
new Promise(res => {
|
new Promise(res => {
|
||||||
gun
|
gun
|
||||||
|
|
@ -527,11 +527,16 @@ const sendHandshakeRequest = async (recipientPublicKey, gun, user, SEA) => {
|
||||||
.get(currentHandshakeAddress)
|
.get(currentHandshakeAddress)
|
||||||
.get(lastRequestIDSentToUser)
|
.get(lastRequestIDSentToUser)
|
||||||
.once(data => {
|
.once(data => {
|
||||||
res(typeof data !== 'undefined')
|
res(data)
|
||||||
})
|
})
|
||||||
})
|
}),
|
||||||
|
// force retry on undefined in case the undefined was a false negative
|
||||||
|
v => typeof v === 'undefined'
|
||||||
)
|
)
|
||||||
|
|
||||||
|
const alreadyContactedOnCurrHandshakeNode =
|
||||||
|
typeof hrInHandshakeNode !== 'undefined'
|
||||||
|
|
||||||
if (alreadyContactedOnCurrHandshakeNode) {
|
if (alreadyContactedOnCurrHandshakeNode) {
|
||||||
throw new Error(ErrorCode.ALREADY_REQUESTED_HANDSHAKE)
|
throw new Error(ErrorCode.ALREADY_REQUESTED_HANDSHAKE)
|
||||||
}
|
}
|
||||||
|
|
|
||||||
Loading…
Add table
Add a link
Reference in a new issue