Fix block tracker not resolving for failed requests#5860
Merged
Conversation
|
Review the following changes in direct dependencies. Learn more about Socket for GitHub.
|
cda8835 to
4a9e3c1
Compare
4a9e3c1 to
8058614
Compare
Upgrade `@metamask/eth-block-tracker` to ^12.0.0 and `@metamask/eth-json-rpc-middleware` to ^17.0.1. This fixes a bug where calls to `getLatestBlock` within middleware would hang if an error was thrown while making the request to the network.
8058614 to
88a682b
Compare
Contributor
Author
|
Marking |
Contributor
Author
|
@metamaskbot publish-previews |
Contributor
|
Preview builds have been published. See these instructions for more information about preview builds. Expand for full list of packages and versions. |
Contributor
Author
|
We are waiting on another fix for the block tracker before merging this. |
Merged
mcmire
added a commit
that referenced
this pull request
May 29, 2025
This release primarily includes the following two fixes to `network-controller`: - Rather than throwing an error, NetworkController now corrects an invalid initial `selectedNetworkClientId` to point to the default RPC endpoint of the first network sorted by chain ID, then logs the error via Sentry ([#5851](#5851)) - Fix the block tracker so that it will now reject if an error is thrown while making the request instead of hanging ([#5860](#5860)) --- Full list of packages and versions in this release: - `@metamask/error-reporting-service` (1.0.0) - `@metamask/network-controller` (23.5.0 -> 23.5.1)
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.
Explanation
Currently, if a consumer makes a request to an RPC endpoint via a network provider object, and that request continually fails in some way and then throws a circuit breaker error, it will never resolve. Naturally, this causes problems if the consuming code (e.g. TransactionController, or UI code) is expecting a response from the network in order to proceed.
This problem occurs because internally the NetworkController wraps requests in special middleware that use the block tracker to get the latest block number. This middleware gets executed before the desired request reaches the network, and in this case because the block tracker does not return a resolved promise, the middleware does not resolve along with the entire request.
This bug has been resolved in
@metamask/eth-block-tracker12.0.1 and@metamask/eth-json-rpc-middleware17.0.1. So, to fix this problem, this PR upgrades these packages.For more see:
@metamask/eth-block-trackerchangelog: https://github.com/MetaMask/eth-block-tracker/blob/main/CHANGELOG.md#1200@metamask/eth-json-rpc-middlewarechangelog: https://github.com/MetaMask/eth-json-rpc-middleware/blob/main/CHANGELOG.md#1701. (There is one breaking change made in 17.0.0, but that doesn't affect our usage of this package.)References
Checklist