avoid endless loops
This commit is contained in:
parent
e5eff0c613
commit
ad61133efe
2 changed files with 11 additions and 18 deletions
|
|
@ -957,7 +957,6 @@ const sendPayment = async (to, amount, memo) => {
|
||||||
// eslint-disable-next-line init-declarations
|
// eslint-disable-next-line init-declarations
|
||||||
let timeoutID
|
let timeoutID
|
||||||
|
|
||||||
/** @type {string} */
|
|
||||||
const invoice = await Promise.race([
|
const invoice = await Promise.race([
|
||||||
Utils.tryAndWait(
|
Utils.tryAndWait(
|
||||||
gun =>
|
gun =>
|
||||||
|
|
@ -979,6 +978,13 @@ const sendPayment = async (to, amount, memo) => {
|
||||||
})
|
})
|
||||||
])
|
])
|
||||||
|
|
||||||
|
if (typeof invoice !== 'string') {
|
||||||
|
throw new Error(
|
||||||
|
'received invoice not an string, isntead got: ' +
|
||||||
|
JSON.stringify(invoice)
|
||||||
|
)
|
||||||
|
}
|
||||||
|
|
||||||
const decInvoice = await SEA.decrypt(invoice, ourSecret)
|
const decInvoice = await SEA.decrypt(invoice, ourSecret)
|
||||||
|
|
||||||
logger.info('decoded invoice: ' + decInvoice)
|
logger.info('decoded invoice: ' + decInvoice)
|
||||||
|
|
|
||||||
|
|
@ -49,23 +49,10 @@ const listenerForAddr = (addr, SEA) => async (order, orderID) => {
|
||||||
)} -- addr: ${addr}`
|
)} -- addr: ${addr}`
|
||||||
)
|
)
|
||||||
|
|
||||||
let hasRetried = false
|
const alreadyAnswered = getUser()
|
||||||
|
.get(Key.ORDER_TO_RESPONSE)
|
||||||
const alreadyAnswered = Utils.tryAndWait(
|
.get(orderID)
|
||||||
(_, user) =>
|
.then()
|
||||||
user
|
|
||||||
.get(Key.ORDER_TO_RESPONSE)
|
|
||||||
.get(orderID)
|
|
||||||
.then(),
|
|
||||||
v => {
|
|
||||||
// only retry once, because of the timeout
|
|
||||||
if (hasRetried) {
|
|
||||||
return false
|
|
||||||
}
|
|
||||||
hasRetried = true
|
|
||||||
return typeof v === 'undefined'
|
|
||||||
}
|
|
||||||
)
|
|
||||||
|
|
||||||
if (alreadyAnswered) {
|
if (alreadyAnswered) {
|
||||||
return
|
return
|
||||||
|
|
|
||||||
Loading…
Add table
Add a link
Reference in a new issue