Skip to content
Open
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
Avoid unscoped coroutine leakage in getSecureWalletInfo() (cancel on …
…invalidate)

(cherry picked from commit 4f2c4cecc238a4e66df4d74829bd53abf98b2839)
  • Loading branch information
MegaManSec committed Feb 16, 2026
commit bc365b49df26506bfcd1a1be5fe7d2b77b3d0b24
6 changes: 5 additions & 1 deletion android/src/main/java/com/expensify/wallet/WalletModule.kt
Original file line number Diff line number Diff line change
Expand Up @@ -21,6 +21,8 @@ import com.google.android.gms.tapandpay.issuer.PushTokenizeRequest
import kotlinx.coroutines.CoroutineScope
import kotlinx.coroutines.Dispatchers
import kotlinx.coroutines.launch
import kotlinx.coroutines.SupervisorJob
import kotlinx.coroutines.cancel
import com.expensify.wallet.Utils.getAsyncResult
import com.expensify.wallet.Utils.toCardData
import com.expensify.wallet.error.InvalidNetworkError
Expand Down Expand Up @@ -50,6 +52,7 @@ class WalletModule internal constructor(context: ReactApplicationContext) :
private val tapAndPayClient: TapAndPayClient = TapAndPay.getClient(activity)
private var pendingCreateWalletPromise: Promise? = null
private var pendingPushTokenizePromise: Promise? = null
private val moduleScope = CoroutineScope(SupervisorJob() + Dispatchers.Main)

override fun initialize() {
super.initialize()
Expand All @@ -58,6 +61,7 @@ class WalletModule internal constructor(context: ReactApplicationContext) :

override fun invalidate() {
super.invalidate()
moduleScope.cancel()
reactApplicationContext.removeActivityEventListener(cardListener)
}

Expand Down Expand Up @@ -119,7 +123,7 @@ class WalletModule internal constructor(context: ReactApplicationContext) :

@ReactMethod
override fun getSecureWalletInfo(promise: Promise) {
CoroutineScope(Dispatchers.Main).launch {
moduleScope.launch {
try {
val walletId = getWalletIdAsync()
val hardwareId = getHardwareIdAsync()
Expand Down