metamask-extension icon indicating copy to clipboard operation
metamask-extension copied to clipboard

feat: Expire duplicate RPC requests after three minutes

Open rekmarks opened this issue 1 year ago • 5 comments

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.

Open in GitHub Codespaces

Related issues

N/A

Manual testing steps

  1. Build the extension under MV3
  2. 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.

rekmarks avatar May 10 '24 18:05 rekmarks

Builds ready [9685326]
Page Load Metrics (1056 ± 647 ms)
PlatformPageMetricMin (ms)Max (ms)Average (ms)StandardDeviation (ms)MarginOfError (ms)
ChromeHomefirstPaint68177962713
domContentLoaded10321563
load56300310561347647
domInteractive10321563
Bundle size diffs [🚨 Warning! Bundle size has increased!]
  • background: 325 Bytes (0.01%)
  • ui: 0 Bytes (0.00%)
  • common: 0 Bytes (0.00%)

metamaskbot avatar May 10 '24 19:05 metamaskbot

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.

codecov[bot] avatar May 10 '24 19:05 codecov[bot]

Can the typescript conversion be split out in a separate PR, preceding the rest of the changes in this one?

legobeat avatar May 13 '24 08:05 legobeat

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

rekmarks avatar May 14 '24 16:05 rekmarks

Builds ready [2483ec7]
Page Load Metrics (951 ± 579 ms)
PlatformPageMetricMin (ms)Max (ms)Average (ms)StandardDeviation (ms)MarginOfError (ms)
ChromeHomefirstPaint57150972713
domContentLoaded96918147
load4627779511207579
domInteractive96918147
Bundle size diffs [🚨 Warning! Bundle size has increased!]
  • background: 365 Bytes (0.01%)
  • ui: 0 Bytes (0.00%)
  • common: 0 Bytes (0.00%)

metamaskbot avatar May 14 '24 17:05 metamaskbot

Builds ready [861e299]
Page Load Metrics (1311 ± 540 ms)
PlatformPageMetricMin (ms)Max (ms)Average (ms)StandardDeviation (ms)MarginOfError (ms)
ChromeHomefirstPaint721731092914
domContentLoaded96221168
load60266013111125540
domInteractive96221168
Bundle size diffs [🚨 Warning! Bundle size has increased!]
  • background: 358 Bytes (0.01%)
  • ui: 0 Bytes (0.00%)
  • common: 0 Bytes (0.00%)

metamaskbot avatar May 20 '24 22:05 metamaskbot

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.

metamaskbot avatar Jun 04 '24 20:06 metamaskbot