Skip to content

fix: don't poll indefinitely for bridge status if 500 errors #6149

New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Merged
merged 27 commits into from
Jul 21, 2025

Conversation

infiniteflower
Copy link
Contributor

@infiniteflower infiniteflower commented Jul 18, 2025

Explanation

This PR fixes an issue where we would poll indefinitely if the Bridge API keeps returning a 500 error. The original bug was that the tx was submitted on the wrong chain and therefore the txHash would never appear on the chain we are querying for, so we would poll the Bridge API indefinitely.

Screenshot 2025-07-18 at 5 04 19 PM

References

Original issue: https://consensyssoftware.atlassian.net/browse/SWAPS-655
Mobile implementation: MetaMask/metamask-mobile#17396

Changelog

Checklist

  • I've updated the test suite for new or updated code as appropriate
  • I've updated documentation (JSDoc, Markdown, etc.) for new or updated code as appropriate
  • I've communicated my changes to consumers by updating changelogs for packages I've changed, highlighting breaking changes as necessary
  • I've prepared draft pull requests for clients and consumer packages to resolve any breaking changes

@infiniteflower infiniteflower changed the title Swaps 655 bridge status indefinite poll 2 fix: don't poll indefinitely for bridge status if 500 errors Jul 18, 2025
@infiniteflower infiniteflower marked this pull request as ready for review July 21, 2025 15:53
@infiniteflower infiniteflower requested a review from a team as a code owner July 21, 2025 15:53
@infiniteflower infiniteflower requested a review from a team as a code owner July 21, 2025 15:55
cursor[bot]

This comment was marked as outdated.

@infiniteflower
Copy link
Contributor Author

@metamaskbot publish-preview

Copy link
Contributor

Preview builds have been published. See these instructions for more information about preview builds.

Expand for full list of packages and versions.
{
  "@metamask-previews/account-tree-controller": "0.4.0-preview-25dbca82",
  "@metamask-previews/accounts-controller": "31.0.0-preview-25dbca82",
  "@metamask-previews/address-book-controller": "6.1.1-preview-25dbca82",
  "@metamask-previews/announcement-controller": "7.0.3-preview-25dbca82",
  "@metamask-previews/app-metadata-controller": "1.0.0-preview-25dbca82",
  "@metamask-previews/approval-controller": "7.1.3-preview-25dbca82",
  "@metamask-previews/assets-controllers": "72.0.0-preview-25dbca82",
  "@metamask-previews/base-controller": "8.0.1-preview-25dbca82",
  "@metamask-previews/bridge-controller": "36.1.0-preview-25dbca82",
  "@metamask-previews/bridge-status-controller": "36.0.0-preview-25dbca82",
  "@metamask-previews/build-utils": "3.0.3-preview-25dbca82",
  "@metamask-previews/chain-agnostic-permission": "1.0.0-preview-25dbca82",
  "@metamask-previews/composable-controller": "11.0.0-preview-25dbca82",
  "@metamask-previews/controller-utils": "11.11.0-preview-25dbca82",
  "@metamask-previews/delegation-controller": "0.5.0-preview-25dbca82",
  "@metamask-previews/earn-controller": "3.0.0-preview-25dbca82",
  "@metamask-previews/eip1193-permission-middleware": "1.0.0-preview-25dbca82",
  "@metamask-previews/ens-controller": "17.0.1-preview-25dbca82",
  "@metamask-previews/error-reporting-service": "2.0.0-preview-25dbca82",
  "@metamask-previews/eth-json-rpc-provider": "4.1.8-preview-25dbca82",
  "@metamask-previews/foundryup": "1.0.0-preview-25dbca82",
  "@metamask-previews/gas-fee-controller": "24.0.0-preview-25dbca82",
  "@metamask-previews/json-rpc-engine": "10.0.3-preview-25dbca82",
  "@metamask-previews/json-rpc-middleware-stream": "8.0.7-preview-25dbca82",
  "@metamask-previews/keyring-controller": "22.1.0-preview-25dbca82",
  "@metamask-previews/logging-controller": "6.0.4-preview-25dbca82",
  "@metamask-previews/message-manager": "12.0.2-preview-25dbca82",
  "@metamask-previews/messenger": "0.0.0-preview-25dbca82",
  "@metamask-previews/multichain-api-middleware": "1.0.0-preview-25dbca82",
  "@metamask-previews/multichain-network-controller": "0.10.0-preview-25dbca82",
  "@metamask-previews/multichain-transactions-controller": "3.0.0-preview-25dbca82",
  "@metamask-previews/name-controller": "8.0.3-preview-25dbca82",
  "@metamask-previews/network-controller": "24.0.0-preview-25dbca82",
  "@metamask-previews/notification-services-controller": "14.0.0-preview-25dbca82",
  "@metamask-previews/permission-controller": "11.0.6-preview-25dbca82",
  "@metamask-previews/permission-log-controller": "3.0.3-preview-25dbca82",
  "@metamask-previews/phishing-controller": "13.1.0-preview-25dbca82",
  "@metamask-previews/polling-controller": "14.0.0-preview-25dbca82",
  "@metamask-previews/preferences-controller": "18.4.1-preview-25dbca82",
  "@metamask-previews/profile-sync-controller": "21.0.0-preview-25dbca82",
  "@metamask-previews/rate-limit-controller": "6.0.3-preview-25dbca82",
  "@metamask-previews/remote-feature-flag-controller": "1.6.0-preview-25dbca82",
  "@metamask-previews/sample-controllers": "1.0.0-preview-25dbca82",
  "@metamask-previews/seedless-onboarding-controller": "2.3.0-preview-25dbca82",
  "@metamask-previews/selected-network-controller": "23.0.0-preview-25dbca82",
  "@metamask-previews/signature-controller": "31.0.1-preview-25dbca82",
  "@metamask-previews/token-search-discovery-controller": "3.3.0-preview-25dbca82",
  "@metamask-previews/transaction-controller": "58.1.1-preview-25dbca82",
  "@metamask-previews/user-operation-controller": "37.0.0-preview-25dbca82"
}

micaelae
micaelae previously approved these changes Jul 21, 2025
@infiniteflower infiniteflower merged commit 6d049eb into main Jul 21, 2025
219 checks passed
@infiniteflower infiniteflower deleted the swaps-655-bridge-status-indefinite-poll-2 branch July 21, 2025 21:14
github-merge-queue bot pushed a commit to MetaMask/metamask-mobile that referenced this pull request Jul 30, 2025
<!--
Please submit this PR as a draft initially.
Do not mark it as "Ready for review" until the template has been
completely filled out, and PR status checks have passed at least once.
-->

## **Description**

<!--
Write a short description of the changes included in this pull request,
also include relevant motivation and context. Have in mind the following
questions:
1. What is the reason for the change?
2. What is the improvement/solution?
-->

This PR fixes an issue where the Bridge API would be polled indefinitely
even if the txHash would never be found (due to a bug where it was
submitted on the wrong chain).

## **Changelog**

<!--
If this PR is not End-User-Facing and should not show up in the
CHANGELOG, you can choose to either:
1. Write `CHANGELOG entry: null`
2. Label with `no-changelog`

If this PR is End-User-Facing, please write a short User-Facing
description in the past tense like:
`CHANGELOG entry: Added a new tab for users to see their NFTs`
`CHANGELOG entry: Fixed a bug that was causing some NFTs to flicker`

(This helps the Release Engineer do their job more quickly and
accurately)
-->

CHANGELOG entry: null

## **Related issues**

Fixes: https://consensyssoftware.atlassian.net/browse/SWAPS-2010

Related to MetaMask/core#6149
Patch is from this branch:
MetaMask/core@main...patch/bridge-status-controller-36.1.0-mobile-ledger-fix

## **Manual testing steps**

1. Modify
`node_modules/@metamask/bridge-status-controller/dist/utils/bridge-status.mjs`
to fetch a fake txHash

```
const fetchBridgeTxStatus = async (statusRequest, clientId, fetchFn, bridgeApiBaseUrl) => {
    const statusRequestDto = (0, exports.getStatusRequestDto)(statusRequest);
    statusRequestDto.srcTxHash = '0xfake';
```

3. Observe that after a failure, polls will follow an exponential
backoff interval (10 sec, 20 sec, etc...)
4. Click on a failed to fetch tx history item (after 7 attempts) to
restart polling. The video below modified the max attempts to 3 for the
sake of a shorter video.

## **Screenshots/Recordings**

<!-- If applicable, add screenshots and/or recordings to visualize the
before and after of your change. -->

### **Before**

<!-- [screenshots/recordings] -->

### **After**

<!-- [screenshots/recordings] -->



https://github.com/user-attachments/assets/14a2b293-94f8-475a-88b1-bc4ac4684f27



## **Pre-merge author checklist**

- [x] 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).
- [x] I've completed the PR template to the best of my ability
- [x] I’ve included tests if applicable
- [ ] I’ve documented my code using [JSDoc](https://jsdoc.app/) format
if applicable
- [x] 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.

## **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.
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

2 participants