Skip to content

fix: Filter out duplicate JSON-RPC requests#24748

Merged
FrederikBolding merged 5 commits into
mainfrom
fb/filter-duped-rpc-requests
Jan 21, 2026
Merged

fix: Filter out duplicate JSON-RPC requests#24748
FrederikBolding merged 5 commits into
mainfrom
fb/filter-duped-rpc-requests

Conversation

@FrederikBolding
Copy link
Copy Markdown
Member

@FrederikBolding FrederikBolding commented Jan 16, 2026

Description

Copies createDupeReqFilterStream.ts from the extension repo and applies it to the provider stream in BackgroundBridge. This filters out any duplicate requests received from the dapp. It is possible for the RPC requests to be duplicated due to the "replay functionality" found here: https://github.com/MetaMask/metamask-mobile/blob/main/scripts/inpage-bridge/src/provider.js#L131

Feedback required.

Changelog

CHANGELOG entry: null


Note

Prevents duplicate JSON-RPC requests from reaching the engines.

  • Add createDupeReqFilterStream with a three-minute expiry for seen request ids; comprehensive unit tests in createDupeReqFilterStream.test.ts
  • Insert filter into BackgroundBridge pump chain for both setupProviderConnectionEip1193 and setupProviderConnectionCaip (between outStream and providerStream)
  • Add @types/readable-stream to dependencies and update lockfile; annotate snaps execution setup with @ts-expect-error for stream type mismatch

Written by Cursor Bugbot for commit 31f5493. This will update automatically on new commits. Configure here.

@metamaskbot metamaskbot added team-core-platform Core Platform team INVALID-PR-TEMPLATE PR's body doesn't match template labels Jan 16, 2026
@FrederikBolding FrederikBolding added skip-sonar-cloud Only used for bypassing sonar cloud when failures are not relevant to the changes. and removed skip-sonar-cloud Only used for bypassing sonar cloud when failures are not relevant to the changes. labels Jan 20, 2026
@FrederikBolding FrederikBolding force-pushed the fb/filter-duped-rpc-requests branch from fc91c5f to cc434dc Compare January 20, 2026 10:01
@FrederikBolding FrederikBolding marked this pull request as ready for review January 20, 2026 17:40
@FrederikBolding FrederikBolding requested review from a team as code owners January 20, 2026 17:40
@socket-security
Copy link
Copy Markdown

socket-security Bot commented Jan 20, 2026

Review the following changes in direct dependencies. Learn more about Socket for GitHub.

Diff Package Supply Chain
Security
Vulnerability Quality Maintenance License
Addednpm/​@​types/​readable-stream@​2.3.151001007485100

View full report

cursor[bot]

This comment was marked as outdated.

jiexi
jiexi previously approved these changes Jan 20, 2026
Copy link
Copy Markdown
Contributor

@cursor cursor Bot left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Cursor Bugbot has reviewed your changes and found 1 potential issue.

Comment thread app/core/BackgroundBridge/createDupeReqFilterStream.test.ts
Comment thread app/core/BackgroundBridge/createDupeReqFilterStream.ts Outdated
Co-authored-by: Maarten Zuidhoorn <maarten@zuidhoorn.com>
@github-actions
Copy link
Copy Markdown
Contributor

🔍 Smart E2E Test Selection

  • Selected E2E tags: FlaskBuildTests, SmokeConfirmationsRedesigned, SmokeWalletPlatform
  • Risk Level: high
  • AI Confidence: 85%
click to see 🤖 AI reasoning details

The changes modify the BackgroundBridge, which is a critical core component that handles all RPC communication between the app and dApps/external connections. The main change adds a duplicate request filter stream (createDupeReqFilterStream) to the provider connection pipeline in both setupProviderConnectionEip1193 and multichain provider connections.

Key impacts:

  1. BackgroundBridge is used by:

    • BrowserTab (dApp browser)
    • SDKConnect (MetaMask SDK connections)
    • WalletConnect (WC sessions)
    • Multichain API connections
  2. The duplicate filter stream is inserted into the pump() pipeline between outStream and providerStream, affecting all JSON-RPC requests flowing through the bridge. While this is a defensive measure to filter duplicate requests, any issues could break dApp interactions.

  3. Snaps execution service has a minor type annotation fix (@ts-expect-error), but snaps also rely on the provider connection through BackgroundBridge.

Selected tags rationale:

  • FlaskBuildTests: Snaps use the provider through BackgroundBridge, and there's a direct change to snaps execution service
  • SmokeConfirmationsRedesigned: All signature and transaction confirmations from dApps flow through BackgroundBridge
  • SmokeWalletPlatform: Core wallet functionality including dApp connections and network switching

The changes are in critical paths (app/core/) and affect the fundamental RPC communication layer, warranting high risk assessment.

View GitHub Actions results

@FrederikBolding FrederikBolding requested a review from jiexi January 21, 2026 09:38
@sonarqubecloud
Copy link
Copy Markdown

@FrederikBolding FrederikBolding added this pull request to the merge queue Jan 21, 2026
Merged via the queue into main with commit 0528810 Jan 21, 2026
93 checks passed
@FrederikBolding FrederikBolding deleted the fb/filter-duped-rpc-requests branch January 21, 2026 18:04
@github-actions github-actions Bot locked and limited conversation to collaborators Jan 21, 2026
@metamaskbot metamaskbot added the release-7.63.0 Issue or pull request that will be included in release 7.63.0 label Jan 21, 2026
Sign up for free to subscribe to this conversation on GitHub. Already have an account? Sign in.

Labels

INVALID-PR-TEMPLATE PR's body doesn't match template release-7.63.0 Issue or pull request that will be included in release 7.63.0 size-M team-core-platform Core Platform team

Projects

None yet

Development

Successfully merging this pull request may close these issues.

5 participants