refactor: Bump eth-json-rpc-provider and related deps#37521
Closed
refactor: Bump eth-json-rpc-provider and related deps#37521
Conversation
Collaborator
✨ Files requiring CODEOWNER review ✨🧩 @MetaMask/extension-devs (5 files, +210 -25)
📜 @MetaMask/policy-reviewers (5 files, +210 -25)
Tip Follow the policy review process outlined in the LavaMoat Policy Review Process doc before expecting an approval from Policy Reviewers. 🔗 @MetaMask/supply-chain (5 files, +210 -25)
🔄 @MetaMask/swaps-engineers (1 files, +2 -2)
|
fd7cc59 to
8f1fb4a
Compare
4 tasks
Collaborator
Builds ready [fdb280b]
UI Startup Metrics (1213 ± 87 ms)
📊 Page Load Benchmark ResultsCurrent Commit: 📄 Localhost MetaMask Test DappSamples: 100 Summary
📈 Detailed Results
Bundle size diffs [🚨 Warning! Bundle size has increased!]
|
rekmarks
added a commit
to MetaMask/core
that referenced
this pull request
Nov 5, 2025
## Explanation Per #6327, migrates `@metamask/eth-json-rpc-provider` to `JsonRpcEngineV2` following its recent introduction. Intended to be closely followed by #6976 and subsequently released. The `InternalProvider` is updated to use `JsonRpcServer` under the hood. It can be constructed with a `JsonRpcServer` or legacy engine, but the latter will be wrapped by a `JsonRpcServer` in order to ensure consistent behavior across all internal providers. Meanwhile, `providerFromEngine()` is removed, it being a useless wrapper over the `InternalProvider` constructor. Elsewhere in the monorepo, these changes revealed a discrepancy in behavior between the error handling of the legacy engine and `asV2Middleware()`, which the latter is amended to resolve. In addition, the changes to the `InternalProvider` revealed that the legacy engine tolerates responses with `{ result: undefined }`. This is impossible to express using the V2 engine, which caused some `NetworkController` tests reliant on the legacy behavior to fail. Further investigation proved that these `undefined` results would error elsewhere in our JSON-RPC pipelines, so we simply remove these test cases. The upshot is that we no longer retry `undefined` results for "child requests" in the `retryOnEmpty` middleware. It is unclear if this was occurring in practice, and it ought to be treated as a breach of contract by the RPC endpoint if it does. ## References - Progresses: #6327 ## 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), highlighting breaking changes as necessary - [x] I've prepared draft pull requests for clients and consumer packages to resolve any breaking changes - Not intended to be shipped without #6976, but it appears we could if we wanted to: - MetaMask/metamask-extension#37521 - MetaMask/metamask-mobile#22154 <!-- CURSOR_SUMMARY --> --- > [!NOTE] > Migrates provider to JsonRpcEngineV2 with updated InternalProvider and helpers, adjusts error/empty-result handling, and updates dependent packages/tests. > > - **eth-json-rpc-provider**: > - Migrate to `JsonRpcEngineV2`; `InternalProvider` now wraps legacy engines via `asV2Middleware`/`JsonRpcEngineV2` and returns results directly. > - Add `providerFromMiddlewareV2`; deprecate `providerFromMiddleware`; remove `providerFromEngine`. > - Switch ID generation from `uuid` to `nanoid`; update exports/tests accordingly. > - **json-rpc-engine (v2)**: > - Add/expand V2 types and exports (`MiddlewareConstraint`, `MergedContextOf`, etc.). > - Update `asV2Middleware` to deserialize errors and ignore `{ error: undefined }` while forwarding results; add tests. > - Rename `unserializeError` to `deserializeError` and adjust usage/tests. > - **eth-json-rpc-middleware**: > - Change `retryOnEmpty` to treat only `null` and `"<nil>"` as empty (stop retrying `undefined`). > - **network-controller**: > - Replace `providerFromEngine` usage with `new InternalProvider({ engine })`. > - Align tests with new empty-result behavior and provider construction. > - **eth-block-tracker tests**: > - Construct providers via `InternalProvider` instead of `providerFromEngine`. > - **Tooling/Config**: > - Add TS/Jest path mapping for `@metamask/json-rpc-engine/v2`. > > <sup>Written by [Cursor Bugbot](https://cursor.com/dashboard?tab=bugbot) for commit 4a63eea. This will update automatically on new commits. Configure [here](https://cursor.com/dashboard?tab=bugbot).</sup> <!-- /CURSOR_SUMMARY -->
fdb280b to
3e486aa
Compare
This comment was marked as outdated.
This comment was marked as outdated.
This comment was marked as outdated.
This comment was marked as outdated.
This comment was marked as outdated.
This comment was marked as outdated.
This comment was marked as outdated.
This comment was marked as outdated.
This comment was marked as outdated.
This comment was marked as outdated.
This comment was marked as outdated.
This comment was marked as outdated.
9d0528a to
4fecebc
Compare
This comment was marked as outdated.
This comment was marked as outdated.
This comment was marked as outdated.
This comment was marked as outdated.
This comment was marked as outdated.
This comment was marked as outdated.
Member
Author
|
@metamaskbot update-policies |
Collaborator
Builds ready [5659eb8]
📊 Page Load Benchmark ResultsCurrent Commit: 📄 Localhost MetaMask Test DappSamples: 100 Summary
📈 Detailed Results
Bundle size diffs [🚨 Warning! Bundle size has increased!]
|
Collaborator
|
Policies updated. 🧠 Learn how: https://lavamoat.github.io/guides/policy-diff/#what-to-look-for-when-reviewing-a-policy-diff |
Collaborator
Builds ready [c35ec24]
UI Startup Metrics (1286 ± 116 ms)
📊 Page Load Benchmark ResultsCurrent Commit: 📄 Localhost MetaMask Test DappSamples: 100 Summary
📈 Detailed Results
Bundle size diffs [🚨 Warning! Bundle size has increased!]
|
Member
Author
|
@metamaskbot update-policies |
Collaborator
|
No policy changes |
Member
Author
|
It's a rousing success. |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
Preview. e2e tests are passing on mobile: MetaMask/metamask-mobile#22154