Commit ae876da
authored
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- packages/transaction-controller
- src
- helpers
- utils
5 files changed
+185
-141
lines changed| Original file line number | Diff line number | Diff line change | |
|---|---|---|---|
| |||
9 | 9 | | |
10 | 10 | | |
11 | 11 | | |
| 12 | + | |
| 13 | + | |
12 | 14 | | |
13 | 15 | | |
14 | 16 | | |
| |||
0 commit comments