feat: stop polling when bridge history item is stale or has an invalid src hash#8479
Merged
feat: stop polling when bridge history item is stale or has an invalid src hash#8479
Conversation
cecef86 to
b0227e9
Compare
b0227e9 to
449f0ed
Compare
statusUpdated
addtxhistory
449f0ed to
28dd789
Compare
Member
Author
|
@metamaskbot publish-preview |
Contributor
|
Preview builds have been published. Learn how to use preview builds in other projects. Expand for full list of packages and versions. |
5b420db to
86fb638
Compare
Member
Author
|
@metamaskbot publish-preview |
Contributor
|
Preview builds have been published. Learn how to use preview builds in other projects. Expand for full list of packages and versions. |
There was a problem hiding this comment.
Cursor Bugbot has reviewed your changes and found 1 potential issue.
❌ Bugbot Autofix is OFF. To automatically fix reported issues with cloud agents, have a team admin enable autofix in the Cursor dashboard.
Reviewed by Cursor Bugbot for commit dbfbe65. Configure here.
infiniteflower
approved these changes
Apr 22, 2026
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 join this conversation on GitHub.
Already have an account?
Sign in to comment
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.

Explanation
Problem
Bridge txHistory persists invalid or premature src tx hashes (specially STX), and pending items could be polled indefinitely, spamming providers and leaving bad state after restarts.
Solution
Subscribe to TransactionController:transactionStatusUpdated instead of transactionFailed / transactionConfirmed, and update history item matching the tx id, action id, hash, batch, or approval
Skips persisting STX src hashes on submit. Set the hash when the tx is confirmed, or backfill from TransactionController as needed
If a transaction is deemed "too old", fetch the status once, then check if the tx has been mined on chain. If The src hash is nonexistent, stop polling and delete the history item to prevent re-polling on the next restart
References
Fixes https://consensyssoftware.atlassian.net/browse/SWAPS-4380
Checklist
Note
Medium Risk
Changes bridge status polling/state management and switches to
TransactionController:transactionStatusUpdated, which can affect analytics, history reconciliation, and when polling starts/stops. Also deletes old pending history entries based on a remote-configured age threshold, so misconfiguration or matching bugs could drop legitimate items.Overview
Prevents indefinite bridge status polling by introducing an age threshold (
maxPendingHistoryItemAgeMs, default 2 days) sourced from remote feature flags and, for stale pending items, fetching status once then checkingeth_getTransactionReceipt; if the src hash appears invalid, polling is stopped, a newinvalid_transaction_hashpolling reason is tracked, and the history entry is removed to avoid re-polling on restart.Refactors BridgeStatusController transaction subscriptions to use
TransactionController:transactionStatusUpdated(replacingtransactionFailed/transactionConfirmed), adds more robust history matching (byid,actionId,batchId,txHash, andapprovalTxId), and avoids persisting smart-transaction src hashes until a finalized status is observed; metrics generation is updated accordingly (centralized polling-status properties and improvederror_messageformatting).Reviewed by Cursor Bugbot for commit dbfbe65. Bugbot is set up for automated code reviews on this repo. Configure here.