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
|
||||
let timeoutID
|
||||
|
||||
/** @type {string} */
|
||||
const invoice = await Promise.race([
|
||||
Utils.tryAndWait(
|
||||
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)
|
||||
|
||||
logger.info('decoded invoice: ' + decInvoice)
|
||||
|
|
|
|||
|
|
@ -49,23 +49,10 @@ const listenerForAddr = (addr, SEA) => async (order, orderID) => {
|
|||
)} -- addr: ${addr}`
|
||||
)
|
||||
|
||||
let hasRetried = false
|
||||
|
||||
const alreadyAnswered = Utils.tryAndWait(
|
||||
(_, user) =>
|
||||
user
|
||||
const alreadyAnswered = getUser()
|
||||
.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'
|
||||
}
|
||||
)
|
||||
.then()
|
||||
|
||||
if (alreadyAnswered) {
|
||||
return
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue