Skip to content

Pending screen can miss its resolution when an earlier Pending screen consumes it #2162

Todo

Description

@jvsena42

Problem

A payment can resolve, but its replacement Pending screen still shows Pending. This happens when an earlier Pending screen for the same payment hash takes the resolution before the replacement screen reads it.

Mechanism

PendingPaymentRepo delivers a resolution two ways:

  • _resolution, a SharedFlow with no replay, for live observers.
  • lastResolutions, which keeps the result for a screen that starts later, read through consumeResolution(hash).

SendPendingViewModel.observeResolution calls consumeResolution(paymentHash) on every resolution it collects (SendPendingViewModel.kt ~330).

When two view models exist for the same hash, the race goes like this:

  1. An earlier SendPendingViewModel (old screen not yet cleared) is still collecting.
  2. A replacement Pending screen for the same hash is created, but its init has not run yet.
  3. resolve emits. The earlier view model collects the resolution and removes it from lastResolutions.
  4. The replacement view model's init calls consumeResolution and gets null. It subscribes after the emit, so it never receives it either.

The replacement screen stays on Pending until the user closes the sheet. Funds and the activity entry are unaffected.

How the second screen can appear

The send sheet can open a new Pending screen for a hash that already has one. One way is QuickPay tracking an earlier send of the same invoice as pending (#2036). This code path is unchanged on master.

Possible direction

The screen that was not shown should not remove the stored result. For example:

  • only consume when pendingPaymentRepo.isActive(paymentHash) matches this view model; or
  • key consumption by view model, rather than having any observer drop the stored resolution.

Notes

Activity

  1. self-assigned this
    on Nov 27, 2026
  2. added this to the 3.3.0 milestone on Nov 27, 2026
  3. ovitrif commented on Nov 27, 2026

    @ovitrif
    Collaborator

    Milestone 3.3.0: this has existed since 3.1.1 and only affects what the screen shows.

    iOS uses the same consume-once slot: AppViewModel.sendSheetPendingResolution, cleared by any SendPendingScreen for that hash through consumeSendSheetPendingResolution. So the same race probably exists there too, though it hasn't been reproduced.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Metadata

Metadata

Assignees

Labels

No labels
No labels

Type

No type

Projects

No projects

    Milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions