feat: Expire duplicate RPC requests after three minutes
Description
Flushes the memorized request ids in the duplicate request middleware every 3 minutes, and makes the middleware ignore JSON-RPC notifications. Also converts the middleware to TypeScript.
The duplicate request middleware used to dedupe JSON-RPC requests with the same id under MV3 used an internal array that would grow boundlessly until the background restarted. In addition, this middleware assumed that it would never see any JSON-RPC notifications (or it would always reject the n + 1:th notifications, since their ids are always undefined). Although we in practice always add ids to JSON-RPC requests, it seems ill-advised for this middleware to make that assumption.
Related issues
N/A
Manual testing steps
- Build the extension under MV3
- Ensure that RPC requests are working correctly
Pre-merge author checklist
- [x] I’ve followed MetaMask Coding Standards.
- [x] I've completed the PR template to the best of my ability
- [x] I’ve included tests if applicable
- [x] I’ve documented my code using JSDoc format if applicable
- [x] I’ve applied the right labels on the PR (see labeling guidelines). 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.
Builds ready [9685326]
- builds: chrome, firefox
- builds (beta): chrome
- builds (flask): chrome, firefox
- builds (MMI): chrome, firefox
- builds (test): chrome, firefox
- builds (test-flask): chrome, firefox
- build viz: Build System
- mv3: Background Module Init Stats
- mv3: UI Init Stats
- mv3: Module Load Stats
- mv3: Bundle Size Stats
- mv2: E2e Actions Stats
- code coverage: Report
- storybook: Storybook
- typescript migration: Dashboard
- all artifacts
Page Load Metrics (1056 ± 647 ms)
| Platform | Page | Metric | Min (ms) | Max (ms) | Average (ms) | StandardDeviation (ms) | MarginOfError (ms) |
|---|---|---|---|---|---|---|---|
| Chrome | Home | firstPaint | 68 | 177 | 96 | 27 | 13 |
| domContentLoaded | 10 | 32 | 15 | 6 | 3 | ||
| load | 56 | 3003 | 1056 | 1347 | 647 | ||
| domInteractive | 10 | 32 | 15 | 6 | 3 |
Bundle size diffs [🚨 Warning! Bundle size has increased!]
- background: 325 Bytes (0.01%)
- ui: 0 Bytes (0.00%)
- common: 0 Bytes (0.00%)
Codecov Report
All modified and coverable lines are covered by tests :white_check_mark:
Project coverage is 67.46%. Comparing base (
55d364d) to head (2483ec7).
:exclamation: Current head 2483ec7 differs from pull request most recent head b9edceb
Please upload reports for the commit b9edceb to get more accurate results.
Additional details and impacted files
@@ Coverage Diff @@
## develop #24487 +/- ##
===========================================
+ Coverage 67.38% 67.46% +0.08%
===========================================
Files 1289 1289
Lines 50235 50263 +28
Branches 13008 13024 +16
===========================================
+ Hits 33849 33906 +57
+ Misses 16386 16357 -29
:umbrella: View full report in Codecov by Sentry.
:loudspeaker: Have feedback on the report? Share it here.
Can the typescript conversion be split out in a separate PR, preceding the rest of the changes in this one?
Can the typescript conversion be split out in a separate PR, preceding the rest of the changes in this one?
@legobeat I don't think a separate PR is worth our time, but I split the initial migration out into its own commit: b029bb6
Builds ready [2483ec7]
- builds: chrome, firefox
- builds (beta): chrome
- builds (flask): chrome, firefox
- builds (MMI): chrome, firefox
- builds (test): chrome, firefox
- builds (test-flask): chrome, firefox
- build viz: Build System
- mv3: Background Module Init Stats
- mv3: UI Init Stats
- mv3: Module Load Stats
- mv3: Bundle Size Stats
- mv2: E2e Actions Stats
- code coverage: Report
- storybook: Storybook
- typescript migration: Dashboard
- all artifacts
Page Load Metrics (951 ± 579 ms)
| Platform | Page | Metric | Min (ms) | Max (ms) | Average (ms) | StandardDeviation (ms) | MarginOfError (ms) |
|---|---|---|---|---|---|---|---|
| Chrome | Home | firstPaint | 57 | 150 | 97 | 27 | 13 |
| domContentLoaded | 9 | 69 | 18 | 14 | 7 | ||
| load | 46 | 2777 | 951 | 1207 | 579 | ||
| domInteractive | 9 | 69 | 18 | 14 | 7 |
Bundle size diffs [🚨 Warning! Bundle size has increased!]
- background: 365 Bytes (0.01%)
- ui: 0 Bytes (0.00%)
- common: 0 Bytes (0.00%)
Builds ready [861e299]
- builds: chrome, firefox
- builds (beta): chrome
- builds (flask): chrome, firefox
- builds (MMI): chrome, firefox
- builds (test): chrome, firefox
- builds (test-flask): chrome, firefox
- build viz: Build System
- mv3: Background Module Init Stats
- mv3: UI Init Stats
- mv3: Module Load Stats
- mv3: Bundle Size Stats
- mv2: E2e Actions Stats
- code coverage: Report
- storybook: Storybook
- typescript migration: Dashboard
- all artifacts
Page Load Metrics (1311 ± 540 ms)
| Platform | Page | Metric | Min (ms) | Max (ms) | Average (ms) | StandardDeviation (ms) | MarginOfError (ms) |
|---|---|---|---|---|---|---|---|
| Chrome | Home | firstPaint | 72 | 173 | 109 | 29 | 14 |
| domContentLoaded | 9 | 62 | 21 | 16 | 8 | ||
| load | 60 | 2660 | 1311 | 1125 | 540 | ||
| domInteractive | 9 | 62 | 21 | 16 | 8 |
Bundle size diffs [🚨 Warning! Bundle size has increased!]
- background: 358 Bytes (0.01%)
- ui: 0 Bytes (0.00%)
- common: 0 Bytes (0.00%)
Missing release label release-11.16.6 on PR. Adding release label release-11.16.6 on PR and removing other release labels(release-11.18.0), as PR was cherry-picked in branch 11.16.6.