From 12d4104d0035c6bba3baff9976e23b2be9cebe9d Mon Sep 17 00:00:00 2001 From: minibits-cash Date: Mon, 28 Sep 2026 21:50:55 +0200 Subject: [PATCH] Remove task queue default timeout from mint ops --- src/models/WalletStore.ts | 7 ++++- .../wallet/operations/meltOperations.ts | 2 -- .../wallet/operations/mintOperations.ts | 1 - .../wallet/operations/receiveOperations.ts | 3 --- .../wallet/operations/revertOperations.ts | 1 - .../wallet/operations/sendOperations.ts | 2 -- .../wallet/operations/syncOperations.ts | 3 +++ src/services/wallet/queueHelper.ts | 26 +++++++++++++------ 8 files changed, 27 insertions(+), 18 deletions(-) diff --git a/src/models/WalletStore.ts b/src/models/WalletStore.ts index 4bd82e77..e44f766c 100644 --- a/src/models/WalletStore.ts +++ b/src/models/WalletStore.ts @@ -380,7 +380,12 @@ export const WalletStoreModel = types } setGlobalRequestOptions({ - headers: {'User-Agent': `Minibits/${JS_BUNDLE_VERSION}`} + headers: {'User-Agent': `Minibits/${JS_BUNDLE_VERSION}`}, + // Down from the cashu-ts default of 300s. Money-moving tasks have no + // queue timeout (see createQueueAwaitable), so this bounds how long + // the user waits for a network failure. NUT-19 cached endpoints + // (swap/melt/mint) are still retried within the mint's ttl. + requestTimeout: 60 * 1000, }) // create cashu-ts mint instance const newMint = new CashuMint(mintUrl) diff --git a/src/services/wallet/operations/meltOperations.ts b/src/services/wallet/operations/meltOperations.ts index 5c13ac5d..b33a8155 100644 --- a/src/services/wallet/operations/meltOperations.ts +++ b/src/services/wallet/operations/meltOperations.ts @@ -48,7 +48,6 @@ const transferQueueAwaitable = ( ): Promise => createQueueAwaitable({ taskFunction: 'transferTask', - timeoutMessage: 'transferQueue timed out', task: () => transferTask( mintBalanceToTransferFrom, @@ -86,7 +85,6 @@ const transferOnchainQueueAwaitable = ( ): Promise => createQueueAwaitable({ taskFunction: 'transferOnchainTask', - timeoutMessage: 'transferOnchainQueue timed out', task: () => transferOnchainTask( mintBalanceToTransferFrom, diff --git a/src/services/wallet/operations/mintOperations.ts b/src/services/wallet/operations/mintOperations.ts index 3f8ba375..01cf5c73 100644 --- a/src/services/wallet/operations/mintOperations.ts +++ b/src/services/wallet/operations/mintOperations.ts @@ -43,7 +43,6 @@ const topupQueueAwaitable = ( ): Promise => createQueueAwaitable({ taskFunction: 'topupTask', - timeoutMessage: 'Topup task timed out', task: () => topupTask( mintBalanceToTopup, diff --git a/src/services/wallet/operations/receiveOperations.ts b/src/services/wallet/operations/receiveOperations.ts index 9e235ea7..458dbb68 100644 --- a/src/services/wallet/operations/receiveOperations.ts +++ b/src/services/wallet/operations/receiveOperations.ts @@ -92,7 +92,6 @@ const receiveQueueAwaitable = ( return createQueueAwaitable({ taskFunction: useBatch ? 'receiveBatchTask' : 'receiveTask', - timeoutMessage: 'receiveQueue timed out', task: async () => { const token = await decodeTokenWithKeysets(encodedToken, mint.mintUrl) return (useBatch @@ -112,7 +111,6 @@ const receiveOfflinePrepareQueueAwaitable = ( return createQueueAwaitable({ taskFunction: 'receiveOfflinePrepareTask', prioritized: false, - timeoutMessage: 'Offline receive prepare timed out', task: () => receiveOfflinePrepareTask( mintUrl, @@ -130,7 +128,6 @@ const receiveOfflineCompleteQueueAwaitable = ( createQueueAwaitable({ taskFunction: 'receiveOfflineCompleteTask', prioritized: false, - timeoutMessage: 'Offline receive complete timed out', task: () => receiveOfflineCompleteTask(transactionId), }) diff --git a/src/services/wallet/operations/revertOperations.ts b/src/services/wallet/operations/revertOperations.ts index 58a08d5a..6f881bbc 100644 --- a/src/services/wallet/operations/revertOperations.ts +++ b/src/services/wallet/operations/revertOperations.ts @@ -8,7 +8,6 @@ const revertQueueAwaitable = ( ): Promise => createQueueAwaitable({ taskFunction: 'revertTask', - timeoutMessage: 'Revert task timed out', task: () => revertTask(transaction), }) diff --git a/src/services/wallet/operations/sendOperations.ts b/src/services/wallet/operations/sendOperations.ts index a18a4109..34f88ec8 100644 --- a/src/services/wallet/operations/sendOperations.ts +++ b/src/services/wallet/operations/sendOperations.ts @@ -17,7 +17,6 @@ const sendQueueAwaitable = ( ): Promise => createQueueAwaitable({ taskFunction: 'sendTask', - timeoutMessage: 'sendQueue timed out', task: () => sendTask( mintBalanceToSendFrom, @@ -38,7 +37,6 @@ const cashuPaymentRequestQueueAwaitable = ( ): Promise => createQueueAwaitable({ taskFunction: 'cashuPaymentRequestTask', - timeoutMessage: 'Cashu payment request timed out', task: () => cashuPaymentRequestTask( mintBalanceToReceiveTo, diff --git a/src/services/wallet/operations/syncOperations.ts b/src/services/wallet/operations/syncOperations.ts index db46a939..63feadc2 100644 --- a/src/services/wallet/operations/syncOperations.ts +++ b/src/services/wallet/operations/syncOperations.ts @@ -27,6 +27,7 @@ import { SYNC_STATE_WITH_ALL_MINTS_TASK, SYNC_STATE_WITH_MINT_TASK, SyncStateTaskResult, + TASK_QUEUE_TIMEOUT, TransactionStateUpdate, WalletTaskResult, } from '../types' @@ -488,6 +489,7 @@ const syncStateWithAllMintsQueueAwaitable = ( ): Promise => createQueueAwaitable({ taskFunction: 'syncSpendableStateTask', + timeoutMs: TASK_QUEUE_TIMEOUT, timeoutMessage: 'Sync all mints state timed out', task: () => syncStateWithAllMintsTask({proofState: options.proofState}), }) @@ -508,6 +510,7 @@ const syncStateWithMintQueueAwaitable = ( return createQueueAwaitable({ taskFunction: SYNC_STATE_WITH_MINT_TASK, prioritized: false, + timeoutMs: TASK_QUEUE_TIMEOUT, timeoutMessage: 'Sync mint state timed out', task: () => syncStateWithMintTask(options), }) diff --git a/src/services/wallet/queueHelper.ts b/src/services/wallet/queueHelper.ts index d423b993..29ce6cf6 100644 --- a/src/services/wallet/queueHelper.ts +++ b/src/services/wallet/queueHelper.ts @@ -1,7 +1,7 @@ import EventEmitter from '../../utils/eventEmitter' import AppError, {Err} from '../../utils/AppError' import {SyncQueue} from '../syncQueueService' -import {TASK_QUEUE_TIMEOUT, WalletTaskResult} from './types' +import {WalletTaskResult} from './types' /** * Shared helper that wraps a task function with the SyncQueue + EventEmitter + @@ -21,7 +21,15 @@ export interface QueueAwaitableOptions { task: () => Promise /** Use addPrioritizedTask when true, otherwise addTask. Defaults to true. */ prioritized?: boolean - /** Timeout in ms before rejecting with TIMEOUT_ERROR. Defaults to TASK_QUEUE_TIMEOUT. */ + /** + * Timeout in ms before rejecting with TIMEOUT_ERROR. Omitted = no timeout. + * + * The timeout only stops the CALLER waiting — the task keeps running in the + * queue and may still move money. Never set it on a task that spends, receives + * or mints ecash: the screen would report "failed" for an operation that is + * still in flight, inviting a retry or an app kill mid-operation. Such tasks + * settle on their own, bounded by the cashu-ts request timeout. + */ timeoutMs?: number /** Message used for the timeout error. */ timeoutMessage?: string @@ -34,7 +42,7 @@ export const createQueueAwaitable = ( taskFunction, task, prioritized = true, - timeoutMs = TASK_QUEUE_TIMEOUT, + timeoutMs, timeoutMessage = `${taskFunction} timed out`, } = options @@ -81,10 +89,12 @@ export const createQueueAwaitable = ( queued.then(resolveOnce).catch(rejectOnce) - setTimeout(() => { - if (!resolved) { - rejectOnce(new AppError(Err.TIMEOUT_ERROR, timeoutMessage)) - } - }, timeoutMs) + if (timeoutMs !== undefined) { + setTimeout(() => { + if (!resolved) { + rejectOnce(new AppError(Err.TIMEOUT_ERROR, timeoutMessage)) + } + }, timeoutMs) + } }) }