Skip to content

Commit ae876da

Browse files
feat: simplify transaction timeout (#7464)
## Explanation Simplify the transaction timeout mechanism to not count attempts, but instead check the time since submit, or when the transaction was last seen on the network. Calculates the timeout duration using the `blockTime` from the accelerated polling feature flags. ## References <!-- Are there any issues that this pull request is tied to? Are there other links that reviewers should consult to understand these changes better? Are there client or consumer pull requests to adopt any breaking changes? For example: * Fixes #12345 * Related to #67890 --> ## 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/contributing.md#updating-changelogs) - [x] I've introduced [breaking changes](https://github.com/MetaMask/core/tree/main/docs/breaking-changes.md) in this PR and have prepared draft pull requests for clients and consumer packages to resolve them <!-- CURSOR_SUMMARY --> --- > [!NOTE] > Replaces attempt-based pending transaction timeout with a time-based check (since submit or last seen), using `blockTime * threshold`, and updates feature flags/tests accordingly. > > - **Transaction logic (`src/helpers/PendingTransactionTracker.ts`)**: > - Replace attempt counter with time-based timeout using `submittedTime` or last seen timestamp; derive timeout from `getAcceleratedPollingParams().blockTime * threshold`. > - Track last-seen times per `hash` via `#lastSeenTimestampByHash`; reset when tx is seen and clear on confirm/fail/drop. > - Use new `#cleanTransaction` to clear force-poll and last-seen state; remove timeout counter usage. > - **Feature flags (`src/utils/feature-flags.ts`)**: > - Add default `blockTime` (12s) and include optional `blockTime` in `acceleratedPolling.perChainConfig`. > - Update `getAcceleratedPollingParams` to return `{ blockTime, countMax, intervalMs }`. > - **Tests**: > - Update `PendingTransactionTracker.test.ts` to use fake timers and validate time-based timeout, last-seen resets, and threshold behavior. > - Extend `feature-flags.test.ts` to assert `blockTime` defaults, per-chain overrides, and merging. > - **Changelog**: > - Note timeout change to time-based and usage of `acceleratedPolling.blockTime`. > > <sup>Written by [Cursor Bugbot](https://cursor.com/dashboard?tab=bugbot) for commit e776a73. This will update automatically on new commits. Configure [here](https://cursor.com/dashboard?tab=bugbot).</sup> <!-- /CURSOR_SUMMARY -->
1 parent deef4bb commit ae876da

File tree

5 files changed

+185
-141
lines changed

5 files changed

+185
-141
lines changed

packages/transaction-controller/CHANGELOG.md

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -9,6 +9,8 @@ and this project adheres to [Semantic Versioning](https://semver.org/spec/v2.0.0
99

1010
### Changed
1111

12+
- Update transaction timeout to check time since submission or when transaction was last seen on network ([#7464](https://github.com/MetaMask/core/pull/7464))
13+
- Uses `blockTime` from `acceleratedPolling` feature flag.
1214
- Deprecate `history` and `sendFlowHistory` properties from `TransactionMeta` and `TransactionController` options ([#7326](https://github.com/MetaMask/core/pull/7326))
1315
- Bump `@metamask/remote-feature-flag-controller` from `^3.0.0` to `^3.1.0` ([#7519](https://github.com/MetaMask/core/pull/7519))
1416
- Bump `@metamask/network-controller` from `^27.0.0` to `^27.1.0` ([#7534](https://github.com/MetaMask/core/pull/7534))

0 commit comments

Comments
 (0)