Skip to content

Commit 1708b0f

Browse files
committed
avoid double-settling Promise in checkWalletAvailability
TapAndPay environment Task invokes onComplete for both success and failure; our handler always resolve()d there, then also reject()d in addOnFailureListener. On failures this meant the same React Native Promise could be settled twice (resolve then reject), causing “Promise already settled” warnings and flaky JS-side behavior. Handle the result in a single callback and resolve once with task.isSuccessful. (cherry picked from commit 6acaa43e50bc63f4ae48746849b36d2f00fe6d48)
1 parent a17cde7 commit 1708b0f

1 file changed

Lines changed: 1 addition & 8 deletions

File tree

android/src/main/java/com/expensify/wallet/WalletModule.kt

Lines changed: 1 addition & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -107,14 +107,7 @@ class WalletModule internal constructor(context: ReactApplicationContext) :
107107
@ReactMethod
108108
override fun checkWalletAvailability(promise: Promise) {
109109
tapAndPayClient.environment.addOnCompleteListener { task ->
110-
if (task.isSuccessful) {
111-
promise.resolve(true)
112-
} else {
113-
promise.resolve(false)
114-
}
115-
}.addOnFailureListener { e ->
116-
promise.reject(E_OPERATION_FAILED, "Checking Wallet availability failed: ${e.localizedMessage}")
117-
}
110+
promise.resolve(task.isSuccessful)
118111
}
119112

120113
@ReactMethod

0 commit comments

Comments
 (0)