diff --git a/api/resolvers/wallet.js b/api/resolvers/wallet.js index cf516d233..c4b84f50f 100644 --- a/api/resolvers/wallet.js +++ b/api/resolvers/wallet.js @@ -9,7 +9,8 @@ import { formatMsats, msatsToSats, msatsToSatsDecimal, satsToMsats } from '@/lib import { USER_ID, INVOICE_RETENTION_DAYS, PAID_ACTION_PAYMENT_METHODS, - WALLET_CREATE_INVOICE_TIMEOUT_MS + WALLET_CREATE_INVOICE_TIMEOUT_MS, + WALLET_RETRY_BACKOFF_MS } from '@/lib/constants' import { amountSchema, validateSchema, withdrawlSchema, lnAddrSchema } from '@/lib/validate' import assertGofacYourself from './ofac' @@ -470,7 +471,7 @@ const resolvers = { SELECT id FROM "Invoice" WHERE "userId" = ${me.id} AND "actionState" = 'FAILED' - AND "userCancel" = false + AND "cancelledAt" < now() - interval '${WALLET_RETRY_BACKOFF_MS} milliseconds' AND "lockedAt" IS NULL ORDER BY id DESC FOR UPDATE SKIP LOCKED diff --git a/lib/constants.js b/lib/constants.js index 3372d9942..dad2dbb18 100644 --- a/lib/constants.js +++ b/lib/constants.js @@ -194,3 +194,7 @@ export const ZAP_UNDO_DELAY_MS = 5_000 export const WALLET_SEND_PAYMENT_TIMEOUT_MS = 150_000 export const WALLET_CREATE_INVOICE_TIMEOUT_MS = 45_000 +// When should failed invoices be returned to a client to retry? +// This must be high enough such that intermediate failed invoices that will be retried +// by the client due to sender or receiver fallbacks are not returned to the client. +export const WALLET_RETRY_BACKOFF_MS = 60_000