chore(runway): cherry-pick fix: handle Perps withdraw batch initialization errors cp-7.78.0#30469
Merged
Merged
Conversation
…ation errors (#30299) ## **Description** Fixes a Perps Withdraw loading state where users could get stuck on the confirmation skeleton if transaction batch initialization failed before an approval request was created. The withdraw flow intentionally navigates to Confirmations early and shows a skeleton loader while the transaction batch is created. This PR adds the same failure escape hatch used by similar mobile flows: if `addTransactionBatch` fails, the app navigates back from the confirmation loader and shows the existing withdrawal failed toast. ## **Changelog** CHANGELOG entry: Fixed a bug that caused Perps Withdraw to stay stuck on a loading screen when withdrawal initialization failed ## **Related issues** Fixes: https://consensyssoftware.atlassian.net/browse/CONF-1392 ## **Manual testing steps** ```gherkin Feature: Perps Withdraw error handling Scenario: user sees an error instead of a stuck loading screen Given the user is on the Perps home screen And Perps withdraw to any token is enabled And withdrawal transaction batch initialization fails When user taps Withdraw Then the confirmation skeleton is dismissed And the user is returned to the previous Perps screen And a withdrawal failed toast is shown ``` ## **Screenshots/Recordings** ### **Before** Users could remain stuck on the confirmation skeleton loader. ### **After** The app navigates back and shows the withdrawal failed toast. ## **Pre-merge author checklist** - [ ] I've followed [MetaMask Contributor Docs](https://github.com/MetaMask/contributor-docs) and [MetaMask Mobile Coding Standards](https://github.com/MetaMask/metamask-mobile/blob/main/.github/guidelines/CODING_GUIDELINES.md). - [ ] I've completed the PR template to the best of my ability - [ ] I've included tests if applicable - [ ] I've documented my code using [JSDoc](https://jsdoc.app/) format if applicable - [ ] I've applied the right labels on the PR (see [labeling guidelines](https://github.com/MetaMask/metamask-mobile/blob/main/.github/guidelines/LABELING_GUIDELINES.md)). Not required for external contributors. #### Performance checks (if applicable) - [ ] I've tested on Android - [ ] I've tested with a power user scenario - [ ] I've instrumented key operations with Sentry traces for production performance metrics ## **Pre-merge reviewer checklist** - [ ] I've manually tested the PR (e.g. pull and build branch, run the app, test code being changed). - [ ] I confirm that this PR addresses all acceptance criteria described in the ticket it closes and includes the necessary testing evidence such as recordings and or screenshots. <!-- CURSOR_SUMMARY --> --- > [!NOTE] > **Medium Risk** > Changes Perps withdraw confirmation flow to handle `addTransactionBatch` failures by navigating back and showing a retry action, which affects user navigation and error handling paths. Risk is moderate due to potential edge cases around retry loops and toast/navigation state. > > **Overview** > Prevents Perps withdraw from getting stuck on the confirmation skeleton by catching `addTransactionBatch` failures in `usePerpsWithdrawConfirmation`, navigating back, and showing a new **retryable** `withdrawalStartFailed` toast that re-attempts initialization. > > Adds the `withdrawalStartFailed(onRetry)` toast option (styled as an error with a "Try again" link) plus new i18n strings, and updates/extends unit tests and mocks to cover the failure + retry behavior and error normalization. > > <sup>Reviewed by [Cursor Bugbot](https://cursor.com/bugbot) for commit a7ae72a. Bugbot is set up for automated code reviews on this repo. Configure [here](https://www.cursor.com/dashboard/bugbot).</sup> <!-- /CURSOR_SUMMARY --> --------- Signed-off-by: dan437 <80175477+dan437@users.noreply.github.com>
Contributor
🔍 Smart E2E Test Selection⏭️ Smart E2E selection skipped - PR targets a release branch (release/*) All E2E tests pre-selected. |
Contributor
|
CLA Signature Action: All authors have signed the CLA. You may need to manually re-run the blocking PR check if it doesn't pass in a few minutes. |
10 tasks
|
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to subscribe to this conversation on GitHub.
Already have an account?
Sign in.
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.



Description
Fixes a Perps Withdraw loading state where users could get stuck on the
confirmation skeleton if transaction batch initialization failed before
an approval request was created.
The withdraw flow intentionally navigates to Confirmations early and
shows a skeleton loader while the transaction batch is created. This PR
adds the same failure escape hatch used by similar mobile flows: if
addTransactionBatchfails, the app navigates back from theconfirmation loader and shows the existing withdrawal failed toast.
Changelog
CHANGELOG entry: Fixed a bug that caused Perps Withdraw to stay stuck on
a loading screen when withdrawal initialization failed
Related issues
Fixes: https://consensyssoftware.atlassian.net/browse/CONF-1392
Manual testing steps
Screenshots/Recordings
Before
Users could remain stuck on the confirmation skeleton loader.
After
The app navigates back and shows the withdrawal failed toast.
Pre-merge author checklist
Docs and MetaMask Mobile
Coding
Standards.
if applicable
guidelines).
Not required for external contributors.
Performance checks (if applicable)
performance metrics
Pre-merge reviewer checklist
app, test code being changed).
in the ticket it closes and includes the necessary testing evidence such
as recordings and or screenshots.
Note
Medium Risk
Changes Perps withdraw confirmation flow to handle
addTransactionBatchfailures by navigating back and showing a retryaction, which affects user navigation and error handling paths. Risk is
moderate due to potential edge cases around retry loops and
toast/navigation state.
Overview
Prevents Perps withdraw from getting stuck on the confirmation
skeleton by catching
addTransactionBatchfailures inusePerpsWithdrawConfirmation, navigating back, and showing a newretryable
withdrawalStartFailedtoast that re-attemptsinitialization.
Adds the
withdrawalStartFailed(onRetry)toast option (styled as anerror with a "Try again" link) plus new i18n strings, and
updates/extends unit tests and mocks to cover the failure + retry
behavior and error normalization.
Reviewed by Cursor Bugbot for commit
a7ae72a. Bugbot is set up for automated
code reviews on this repo. Configure
here.
Signed-off-by: dan437 80175477+dan437@users.noreply.github.com b5b803d