View Issue Details

IDProjectCategoryView StatusLast Update
0011983Talerwallet (iOS App)public2026-11-19 08:47
Reporterbot-cg [agent]  
ImplementerMarcS  
PrioritynormalSeverityminor 
Status implementing 
Summary0011983: Deposit: nothing bounds how long "Depositing..." waits -- the wallet-core channel has no deadline, and Abort dismisses the screen without cancelling
DescriptionNothing on the deposit path bounds how long the app will wait for
wallet-core. If the answer never comes, "Depositing..." spins for as long
as the user is prepared to look at it, and the one control on the screen
does not cancel anything.

**There is no deadline anywhere on the path.**

* `DepositAmountAction.startDeposit` (TalerWallet1/Views/Actions/Banking/
  DepositAmountAction.swift:78-93) sets `depositStarted = true` and awaits
  `model.createDepositGroup(...)` in a `Task` with no timeout.
* `WalletModel.sendRequest` (TalerWallet1/Model/WalletModel.swift:189-211)
  awaits and rethrows; it has no timeout.
* `WalletCore.sendFormattedRequest` (TalerWallet1/Backend/
  WalletCore.swift:626-629) is a bare
  `withCheckedThrowingContinuation`. If wallet-core never calls back, the
  continuation is never resumed and the `await` never returns. There is no
  deadline in the channel at all, for any operation.

**And `createDepositGroup` really does wait on the network.** In
wallet-core it calls `getExchangesForDeposit`
(taler-wallet-core/src/deposits.ts, inside `createDepositGroup`), so an
exchange that does not answer is enough to produce the state above.

**What the user is left with.** While `depositStarted` is true the view is
a `LoadingView("Depositing...")` with `navigationBarBackButtonHidden(true)`
and `interactiveDismissDisabled()` -- the back gesture and the back button
are both gone on purpose -- and a single "Abort" button whose action is
`dismissTop(stack.push())` (:109-118). That dismisses the screen. It does
not cancel the `Task`, does not cancel the wallet-core request, and says
nothing about what happened to the deposit. So the choices are: wait with
no stated limit, or leave with no answer.

**This is about a non-answer, not a swallowed error.** An error *does*
surface here: `createDepositGroup` is called with the default
`viewHandles: false`, so `sendRequest`'s catch calls `setError`
(WalletModel.swift:174-180) and the user gets an alert. That is the
difference from 11980, where wallet-core answered 7046 and the view
discarded it with `try?`. Here the complaint is the case wallet-core never
answers, which no amount of error handling reaches.

**Why 30 s is the right order of magnitude.** The exchange round trips
inside a deposit are the same ones a withdrawal makes, and on the harness's
own deployment a full bank-integrated withdrawal reaches `Done` in about
30 s end to end, of which 30 s is one deliberate `timeout_ms=30000` long
poll on `/reserves`. A deposit that has not answered in 30 s is not a slow
network.

**Not deposit-specific.** The missing deadline is in the shared channel,
so every operation inherits it. Deposit is where it shows worst because
this screen deliberately removes the exits; `withdraw` and the P2P screens
reach the same continuation.
Steps To Reproduce1. Fund a wallet (empty-wallet screen -> "Get demo cash", KUDOS 25) and add
   a bank account (Settings -> Bank Accounts -> +, any valid IBAN).
2. Make wallet-core's responses disappear, using the app's own dev
   experiment facility -- no proxy needed:

       xcrun simctl openurl booted \
         'taler://dev-experiment/start-tc?drop_resp=1'

3. Actions -> Deposit -> the account -> enter an amount -> "Deposit <amount>".

Observed: "Depositing..." with no back button, no swipe-to-dismiss and an
"Abort" button. It stays. Abort returns to the previous screen without
cancelling the operation or saying what became of it.

Expected: a deadline -- some tens of seconds -- after which the screen says
the deposit could not be confirmed and offers a retry; and an Abort that
cancels rather than just hides.

Found while measuring the harness's deterministic `deposit` scenario, whose
step budget for this tap was 240 s. That budget is now 30 s, and a new
scenario `deposit-no-response` performs exactly the three steps above and
asserts that something appears within it.
Additional InformationSuggested shape, smallest first:

1. A deadline at the call site, which needs no change to the channel:

       let result = try await withThrowingTaskGroup(of: DepositGroupResult?.self) { g in
           g.addTask { try await model.createDepositGroup(...) }
           g.addTask { try? await Task.sleep(nanoseconds: 30_000_000_000); return nil }
           let first = try await g.next()
           g.cancelAll()
           return first ?? nil
       }

   with `nil` rendered as "the deposit could not be confirmed" plus a retry.

2. Better, because every screen inherits it: a timeout in
   `WalletCore.sendFormattedRequest`, resuming the continuation with a
   timeout error when wallet-core has not answered within some per-operation
   budget. The budget cannot be one number for every operation -- a
   withdrawal's own long poll is 30 s by design -- so it would have to be a
   property of the request type.

3. Separately, "Abort" should cancel. It currently calls `dismissTop`, so
   the `Task` and the wallet-core operation both continue behind a screen
   the user has left.

Related: 11980 (same flow family, but there wallet-core answered and the
view dropped the answer), 11937 (loading states shown for operations that
finish in 21-50 ms -- the same `LoadingView`, the opposite end of the same
missing policy).
TagsNo tags attached.
Attached Files
11983-deposit-deadline.diff (6,831 bytes)   
diff --git a/TalerWallet1/Views/Actions/Banking/DepositAmountAction.swift b/TalerWallet1/Views/Actions/Banking/DepositAmountAction.swift
index 8ffae2ec..48fb7f37 100644
--- a/TalerWallet1/Views/Actions/Banking/DepositAmountAction.swift
+++ b/TalerWallet1/Views/Actions/Banking/DepositAmountAction.swift
@@ -22,7 +22,22 @@ struct DepositAmountAction: View {
     @EnvironmentObject private var controller: Controller
     @EnvironmentObject private var model: WalletModel
 
+    @AppStorage("developerMode") var developerMode: Bool = false
+
     @State private var balanceIndex = 0
+    /// The deposit in flight, so "Abort" can stop waiting for it.
+    ///
+    /// It could not: `Abort`'s action is `dismissTop`, which hides the
+    /// screen and leaves the `Task` running.  Issue 11983.
+    ///
+    /// What this does NOT do, and the comment is here so nobody reads more
+    /// into it: cancelling the Swift task stops the UI waiting, and does
+    /// not cancel the operation inside wallet-core.  Aborting that needs a
+    /// wallet-core-side abort for the deposit group, which the app has no
+    /// request for.
+    @State private var depositTask: Task<Void, Never>? = nil
+    /// Why the deposit did not start, if it did not.
+    @State private var depositError: Error? = nil
     /// Bumped on every `.BalanceChange`, and folded into the task id below.
     ///
     /// The maximum this screen shows is read once per balance selection:
@@ -97,24 +112,80 @@ struct DepositAmountAction: View {
         }
     }
 
+    /// How long to wait for wallet-core to create the deposit group.
+    ///
+    /// Nothing on this path bounded the wait: not this call site, not
+    /// `WalletModel.sendRequest`, and not
+    /// `WalletCore.sendFormattedRequest`, which is a bare
+    /// `withCheckedThrowingContinuation` -- if wallet-core never calls
+    /// back, the `await` never returns and "Depositing..." stays for as
+    /// long as the user looks at it.  Issue 11983.
+    ///
+    /// 30 s because the exchange round trips inside `createDepositGroup`
+    /// are the ones a withdrawal also makes, and a full bank-integrated
+    /// withdrawal reaches `Done` in about 30 s on this harness -- of which
+    /// 30 s is one deliberate `timeout_ms=30000` long poll on `/reserves`.
+    /// A deposit that has not answered in 30 s is not a slow network.
+    private static let depositDeadlineS: UInt64 = 30
+
     @MainActor
     private func startDeposit(_ scope: ScopeInfo) {
         if let paytoUri {
             depositStarted = true    // don't run twice
-            Task {
+            depositError = nil
+            depositTask = Task {
                 symLog.log("Deposit")
-                if let result = try? await model.createDepositGroup(paytoUri,
-                                                                    scope: scope,
-                                                                    amount: amountToTransfer) {
+                do {
+                    let result = try await withDeadline {
+                        try await model.createDepositGroup(paytoUri,
+                                                            scope: scope,
+                                                           amount: amountToTransfer)
+                    }
+                    guard let result else {
+                        symLog.log("createDepositGroup did not answer in "
+                                   + "\(Self.depositDeadlineS)s")
+                        depositError = WalletBackendError.deserializationError
+                        depositStarted = false
+                        return
+                    }
                     symLog.log(result.transactionId)
                     txId = result.transactionId
-                } else {
+                } catch is CancellationError {
+                    // Abort. The user asked to stop waiting.
+                    depositStarted = false
+                } catch {
+                    symLog.log("createDepositGroup failed: \(error)")
+                    depositError = error
                     depositStarted = false
                 }
             }
         }
     }
 
+    /// `work()`, or nil if it has not answered within the deadline.
+    ///
+    /// A race rather than a timeout on the request, because the deadline
+    /// this is fixing is missing from the whole channel and a per-request
+    /// budget cannot be one number -- a withdrawal's own long poll is 30 s
+    /// by design.  Deciding that properly belongs in
+    /// `sendFormattedRequest`; this bounds the one screen that removes its
+    /// own exits while it waits.
+    private func withDeadline(
+        _ work: @escaping @Sendable () async throws -> DepositGroupResult
+    ) async throws -> DepositGroupResult? {
+        try await withThrowingTaskGroup(of: DepositGroupResult?.self) { group in
+            group.addTask { try await work() }
+            group.addTask {
+                try? await Task.sleep(nanoseconds:
+                    Self.depositDeadlineS * 1_000_000_000)
+                return nil
+            }
+            let first = try await group.next() ?? nil
+            group.cancelAll()
+            return first
+        }
+    }
+
     var body: some View {
 #if PRINT_CHANGES
         let _ = Self._printChanges()
@@ -128,6 +199,9 @@ struct DepositAmountAction: View {
                                 showDone: .prominent,       // TODO: isKYC ? .bordered : .prominent
                                      url: nil,
                              withActions: false)
+        } else if let depositError {
+            ErrorView(stack.push(), error: depositError,
+                      devMode: developerMode) { self.depositError = nil }
         } else if depositStarted {
             let message = String(localized: "Depositing...", comment: "loading")
             LoadingView(stack: stack.push(), scopeInfo: nil, message: message)
@@ -135,7 +209,13 @@ struct DepositAmountAction: View {
                 .interactiveDismissDisabled()           // can only use "Abort" button to dismiss
                 .safeAreaInset(edge: .bottom) {
                     let buttonTitle = String(localized: "Abort", comment: "deposit")
-                    Button(buttonTitle) { dismissTop(stack.push()) }
+                    Button(buttonTitle) {
+                        // Cancel, then leave. `dismissTop` alone hid the
+                        // screen and left the task running (11983).
+                        depositTask?.cancel()
+                        depositStarted = false
+                        dismissTop(stack.push())
+                    }
                         .buttonStyle(TalerButtonStyle(type: .prominent))
                         .padding(.horizontal)
                 }
11983-deposit-deadline.diff (6,831 bytes)   

Required notifications

Address or linkRemarkAdded byNotifiedActions

Activities

bot-cg [agent]

2026-11-09 22:33

updater   ~0030359

Patch attached: `11983-deposit-deadline.diff`. It is the modest half of
this report, and the limits matter more than the code.

What it does:

* a 30 s deadline on `createDepositGroup`, as a race in
  `withThrowingTaskGroup` against `Task.sleep` -- `withDeadline` in
  `DepositAmountAction`;
* an error branch in `body`, so a refusal is shown on the screen rather
  than only through the global presentation;
* `Abort` calls `depositTask?.cancel()` before `dismissTop`, where it
  previously only hid the screen.

What it does NOT do, and the patch says so in comments rather than leaving
it to be discovered:

* **Cancelling the Swift task does not cancel the operation inside
  wallet-core.** The task stops waiting; the deposit group may still be
  created. Aborting it for real needs a wallet-core-side abort the app has
  no request for. So "Abort" now means "stop waiting", which is strictly
  better than "hide the screen and keep waiting invisibly" and is still not
  what the word promises.
* **The deadline is at the call site, not in the channel.** The report
  argues the better fix is in `WalletCore.sendFormattedRequest`, whose bare
  `withCheckedThrowingContinuation` is why no operation anywhere has a
  bound. That cannot be one number -- a withdrawal's own long poll is 30 s
  by design -- so it needs a per-request budget, which is a design decision
  and not a bug fix. This patch bounds the one screen that removes its own
  exits while it waits.
* 30 s is argued from measurement rather than taste: the exchange round
  trips inside `createDepositGroup` are the ones a withdrawal also makes,
  and a full bank-integrated withdrawal reaches `Done` in about 30 s on
  this harness, of which 30 s is one deliberate `timeout_ms=30000` long
  poll on `/reserves`.

Built against iOS 27.2, Xcode 27.2: compiles, and both new literals are in
the built binary. The timeout path itself is exercised by a new
deterministic scenario, `deposit-no-response`, which presses Deposit with
wallet-core's responses dropped
(`taler://dev-experiment/start-tc?drop_resp=1`) and asserts what the screen
says 30 s later. That scenario currently cannot reach its own subject for a
different reason -- 11984 -- so the patch's behaviour is compiled and not
yet observed.

For `DepositAmountAction.swift` the order of today's three patches is
**11984, then 11982, then 11983**; each diff is one commit and applies to
its predecessor.

Issue History

Date ModifiedUsernameFieldChange
2026-11-09 20:13bot-cgNew Issue
2026-11-09 22:21Christian GrothoffImplementer => MarcS
2026-11-09 22:21Christian GrothoffReviewer => avalos
2026-11-09 22:21Christian GrothoffRelease signed by => MarcS
2026-11-09 22:21Christian GrothoffDeployed by => MarcS
2026-11-09 22:21Christian GrothoffVerifier => MarcS
2026-11-09 22:21Christian GrothoffStatusnew => planning
2026-11-09 22:32bot-cgFile Added: 11983-deposit-deadline.diff
2026-11-09 22:33bot-cgNote Added: 0030359
2026-11-19 08:47Christian GrothoffStatusplanning => implementing