Skip to content

[Android] Cancel polling jobs on wallet switch in TransactionsRepository #526

Description

@DRadmir

pollTransactionStatus jobs are launched per pending transaction and tracked in
pollingTransactionJobs (ConcurrentHashMap). A job removes itself in finally
when its transaction finalizes or times out, but it is NOT cancelled when the
transaction leaves the observed set — e.g. on wallet switch.
observePollingTransactions' flatMapLatest swaps the upstream, yet jobs started
for the previous wallet keep network-polling until their own tx resolves.

This is not an unbounded leak (self-cleaning, bounded by pending count), but
stale jobs do extra polling after a wallet switch.

Proposal: in the collect, diff the current id set against
pollingTransactionJobs.keys and cancel jobs no longer present; or scope job
lifetime to the current walletId. No change to status-polling semantics.

File: android/data/repositories/src/main/kotlin/com/gemwallet/android/data/repositories/transactions/TransactionsRepositoryImpl.kt
(observePollingTransactions ~line 181, pollTransactionStatus ~line 199)

Metadata

Metadata

Assignees

Labels

Type

No type
No fields configured for issues without a type.

Projects

No projects

Milestone

No milestone

Relationships

None yet

Development

No branches or pull requests

Issue actions