feat: using websockets events for transaction polling#7822
Merged
Conversation
70ae62d to
41a0567
Compare
e9cf4eb to
45493b2
Compare
matthewwalsh0
requested changes
Feb 4, 2026
packages/transaction-controller/src/helpers/TransactionPoller.ts
Outdated
Show resolved
Hide resolved
packages/transaction-controller/src/helpers/TransactionPoller.ts
Outdated
Show resolved
Hide resolved
packages/transaction-controller/src/helpers/TransactionPoller.ts
Outdated
Show resolved
Hide resolved
packages/transaction-controller/src/helpers/TransactionPoller.ts
Outdated
Show resolved
Hide resolved
packages/transaction-controller/src/helpers/TransactionPoller.ts
Outdated
Show resolved
Hide resolved
packages/transaction-controller/src/helpers/TransactionPoller.ts
Outdated
Show resolved
Hide resolved
packages/transaction-controller/src/helpers/TransactionPoller.ts
Outdated
Show resolved
Hide resolved
…/MetaMask/core into transaction_polling_improvements
…ion_polling_improvements
matthewwalsh0
requested changes
Feb 5, 2026
packages/transaction-controller/src/helpers/TransactionPoller.ts
Outdated
Show resolved
Hide resolved
packages/transaction-controller/src/helpers/TransactionPoller.ts
Outdated
Show resolved
Hide resolved
packages/transaction-controller/src/helpers/TransactionPoller.ts
Outdated
Show resolved
Hide resolved
matthewwalsh0
approved these changes
Feb 8, 2026
| } | ||
|
|
||
| if ( | ||
| transaction.status !== 'confirmed' && |
Member
There was a problem hiding this comment.
Minor, could do a ![...].includes(transaction.status)?
| return; | ||
| } | ||
|
|
||
| const isPendingTransaction = this.#pendingTransactions?.some( |
Member
There was a problem hiding this comment.
Minor, this is great, but does it negate the need for the selected account check above?
Contributor
Author
There was a problem hiding this comment.
That is good point, I can update in a coming PR
github-merge-queue bot
pushed a commit
that referenced
this pull request
Feb 9, 2026
## Explanation Small transaction poller cleanup PR. Discussion here: #7822 (comment) ## References * Related to MetaMask/MetaMask-planning#6948 ## Checklist - [X] I've updated the test suite for new or updated code as appropriate - [X] I've updated documentation (JSDoc, Markdown, etc.) for new or updated code as appropriate - [X] I've communicated my changes to consumers by [updating changelogs for packages I've changed](https://github.com/MetaMask/core/tree/main/docs/processes/updating-changelogs.md) - [X] I've introduced [breaking changes](https://github.com/MetaMask/core/tree/main/docs/processes/breaking-changes.md) in this PR and have prepared draft pull requests for clients and consumer packages to resolve them <!-- CURSOR_SUMMARY --> --- > [!NOTE] > **Medium Risk** > Changes when websocket-driven polling is triggered, which could increase polling or cause unintended refreshes if unrelated transaction update events match pending hashes. > > **Overview** > `TransactionPoller` no longer filters `AccountActivityService:transactionUpdated` events by chain ID (CAIP-2 conversion) or by the selected account address; it now triggers a poll for any `confirmed`/`dropped`/`failed` event whose `transaction.id` matches a pending transaction `hash`. > > Tests were updated to reflect the relaxed filtering (simpler messenger mock, removed non-matching chain/account cases, and adjusted expectations/descriptions). > > <sup>Written by [Cursor Bugbot](https://cursor.com/dashboard?tab=bugbot) for commit cd0baa2. This will update automatically on new commits. Configure [here](https://cursor.com/dashboard?tab=bugbot).</sup> <!-- /CURSOR_SUMMARY -->
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
Using event AccountActivityService:transactionUpdated to improve transaction polling.
References
Fixes https://github.com/MetaMask/MetaMask-planning/issues/6948
Checklist
Note
Medium Risk
Changes core transaction polling behavior by introducing a new event-driven trigger and additional filtering logic (chain/account/hash/status), which could affect how quickly transactions update or how often polling runs if the event stream is noisy or mismatched.
Overview
Adds event-driven pending transaction polling by having
TransactionPollersubscribe toAccountActivityService:transactionUpdatedand trigger an immediate poll when an update matches the currentchainId, is a terminal status (confirmed/dropped/failed), is from the selected account, and corresponds to a currently pending tx hash.Refactors CAIP-2 chain-id conversion into a shared
caip2ToHexutility (used by bothTransactionPollerandIncomingTransactionHelper) and adds unit coverage for the new websocket trigger behavior and CAIP parsing; changelog is updated to announce the new polling mode.Written by Cursor Bugbot for commit bec1c47. This will update automatically on new commits. Configure here.