From 14acff10a93bbdaaa600a15a60b063b41e28aec0 Mon Sep 17 00:00:00 2001 From: Brandon McAnsh Date: Sat, 30 May 2026 21:01:09 -0400 Subject: [PATCH] fix(onramp): re-throw CancellationException in buildSwapTransaction When users navigate away from the Swap screen during Phantom transaction building, viewModelScope cancellation was caught by the generic catch(Exception) block and wrapped as FailedToCreateTransaction, causing ~3,730 spurious Bugsnag events. Re-throw CancellationException to let coroutine cancellation propagate naturally. --- .../kotlin/com/flipcash/app/onramp/PhantomWalletController.kt | 3 +++ 1 file changed, 3 insertions(+) diff --git a/apps/flipcash/shared/onramp/deeplinks/src/main/kotlin/com/flipcash/app/onramp/PhantomWalletController.kt b/apps/flipcash/shared/onramp/deeplinks/src/main/kotlin/com/flipcash/app/onramp/PhantomWalletController.kt index c3d7ec8ce..11b8432e0 100644 --- a/apps/flipcash/shared/onramp/deeplinks/src/main/kotlin/com/flipcash/app/onramp/PhantomWalletController.kt +++ b/apps/flipcash/shared/onramp/deeplinks/src/main/kotlin/com/flipcash/app/onramp/PhantomWalletController.kt @@ -37,6 +37,7 @@ import dev.bmcreations.phantom.connect.ConnectResult import dev.bmcreations.phantom.connect.PhantomSdk import dev.bmcreations.phantom.connect.wallet.PhantomWalletConnector import dev.bmcreations.phantom.connect.wallet.PhantomWalletException +import kotlin.coroutines.cancellation.CancellationException import kotlinx.coroutines.Dispatchers import kotlinx.coroutines.NonCancellable import kotlinx.coroutines.withContext @@ -225,6 +226,8 @@ class PhantomWalletController @Inject constructor( } Result.success(transaction to swapId) + } catch (e: CancellationException) { + throw e } catch (e: Exception) { trace("External swap failed", type = TraceType.Error, error = e) Result.failure(