Skip to content

Continue to retry failed requests when offline#8623

Open
mcmire wants to merge 4 commits intomainfrom
still-retry-requests-when-offline
Open

Continue to retry failed requests when offline#8623
mcmire wants to merge 4 commits intomainfrom
still-retry-requests-when-offline

Conversation

@mcmire
Copy link
Copy Markdown
Contributor

@mcmire mcmire commented Apr 28, 2026

Explanation

In a previous commit, a change was made where NetworkController would no longer retry failed requests if it detected that the user was offline. The ultimate goal was to prevent NetworkController:rpcEndpointChainDegraded and NetworkController:rpcEndpointChainUnavailable from being published, because these events are used to report issues to Segment about networks that have become degraded or unavailable.

Since then, we have discovered that the logic to detect whether user is offline or online is not exactly reliable, and it may be possible for NetworkController to get stuck in an offline state. If that were to happen, then if the user were experiencing intermittent connectivity issues, failed requests would never get retried until MetaMask was restarted.

This is not good from a user experience. And anyway, we don't have to do this. We can continue to retry requests and prevent degraded and/or unavailable events from getting published. This commit updates the logic in RpcService accordingly.

References

(Ongoing issue with Morpho; see Slack)

Checklist

  • I've updated the test suite for new or updated code as appropriate
  • I've updated documentation (JSDoc, Markdown, etc.) for new or updated code as appropriate
  • I've communicated my changes to consumers by updating changelogs for packages I've changed
  • I've introduced breaking changes in this PR and have prepared draft pull requests for clients and consumer packages to resolve them

Note

Medium Risk
Changes retry/circuit-breaker behavior for RPC requests when offline, which can affect request load and how network availability/degradation analytics events are emitted.

Overview
Restores retry behavior while offline. RpcService no longer disables retryFilterPolicy when isOffline() is true, so transient failures still get retried even if offline detection is inaccurate.

Suppresses offline telemetry-style callbacks instead. When offline, RpcService now skips invoking onDegraded and onBreak listeners (but still retries), and tests were updated to remove “no retry offline” assertions while keeping expectations that NetworkController:*Unavailable/*Degraded events are not published when offline.

Adds a changelog entry documenting the fix and updates lint suppression counts.

Reviewed by Cursor Bugbot for commit 892d98e. Bugbot is set up for automated code reviews on this repo. Configure here.

In a previous commit, a change was made where NetworkController would no
longer retry failed requests if it detected that the user was offline.
The ultimate goal was to prevent
`NetworkController:rpcEndpointChainDegraded` and
`NetworkController:rpcEndpointChainUnavailable` from being published,
because these events are used to report issues to Segment about networks
that have become degraded or unavailable.

Since then, we have discovered that the logic to detect whether user is
offline or online is not exactly reliable, and it may be possible for
NetworkController to get stuck in an offline state. If that were to
happen, then if the user were experiencing intermittent connectivity
issues, failed requests would never get retried until MetaMask was
restarted.

This is not good from a user experience. And anyway, we don't have to do
this. We can continue to retry requests *and* prevent the degraded
and/or unavailable events from getting published. This commit makes that
happen.
@mcmire mcmire marked this pull request as ready for review April 28, 2026 20:02
@mcmire mcmire requested review from a team as code owners April 28, 2026 20:02
@mcmire
Copy link
Copy Markdown
Contributor Author

mcmire commented Apr 28, 2026

@metamaskbot publish-previews

Copy link
Copy Markdown

@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.

Fix All in Cursor

❌ Bugbot Autofix is OFF. To automatically fix reported issues with cloud agents, have a team admin enable autofix in the Cursor dashboard.

Reviewed by Cursor Bugbot for commit 1614749. Configure here.

Comment thread packages/network-controller/src/rpc-service/rpc-service.test.ts Outdated
@github-actions
Copy link
Copy Markdown
Contributor

Preview builds have been published. Learn how to use preview builds in other projects.

Expand for full list of packages and versions.
@metamask-previews/account-tree-controller@7.1.0-preview-1614749c0
@metamask-previews/accounts-controller@37.2.0-preview-1614749c0
@metamask-previews/address-book-controller@7.1.1-preview-1614749c0
@metamask-previews/ai-controllers@0.6.3-preview-1614749c0
@metamask-previews/analytics-controller@1.0.1-preview-1614749c0
@metamask-previews/analytics-data-regulation-controller@0.0.0-preview-1614749c0
@metamask-previews/announcement-controller@8.1.0-preview-1614749c0
@metamask-previews/app-metadata-controller@2.0.1-preview-1614749c0
@metamask-previews/approval-controller@9.0.1-preview-1614749c0
@metamask-previews/assets-controller@6.2.0-preview-1614749c0
@metamask-previews/assets-controllers@104.3.0-preview-1614749c0
@metamask-previews/authenticated-user-storage@1.0.0-preview-1614749c0
@metamask-previews/base-controller@9.1.0-preview-1614749c0
@metamask-previews/base-data-service@0.1.1-preview-1614749c0
@metamask-previews/bridge-controller@70.2.0-preview-1614749c0
@metamask-previews/bridge-status-controller@71.0.0-preview-1614749c0
@metamask-previews/build-utils@3.0.4-preview-1614749c0
@metamask-previews/chain-agnostic-permission@1.5.0-preview-1614749c0
@metamask-previews/chomp-api-service@2.0.0-preview-1614749c0
@metamask-previews/claims-controller@0.5.0-preview-1614749c0
@metamask-previews/client-controller@1.0.1-preview-1614749c0
@metamask-previews/compliance-controller@2.0.0-preview-1614749c0
@metamask-previews/composable-controller@12.0.1-preview-1614749c0
@metamask-previews/config-registry-controller@0.2.0-preview-1614749c0
@metamask-previews/connectivity-controller@0.2.0-preview-1614749c0
@metamask-previews/controller-utils@11.20.0-preview-1614749c0
@metamask-previews/core-backend@6.2.1-preview-1614749c0
@metamask-previews/delegation-controller@3.0.0-preview-1614749c0
@metamask-previews/earn-controller@12.0.0-preview-1614749c0
@metamask-previews/eip-5792-middleware@3.0.3-preview-1614749c0
@metamask-previews/eip-7702-internal-rpc-middleware@0.1.0-preview-1614749c0
@metamask-previews/eip1193-permission-middleware@1.0.3-preview-1614749c0
@metamask-previews/ens-controller@19.1.1-preview-1614749c0
@metamask-previews/eth-block-tracker@15.0.1-preview-1614749c0
@metamask-previews/eth-json-rpc-middleware@23.1.3-preview-1614749c0
@metamask-previews/eth-json-rpc-provider@6.0.1-preview-1614749c0
@metamask-previews/foundryup@1.0.1-preview-1614749c0
@metamask-previews/gas-fee-controller@26.1.1-preview-1614749c0
@metamask-previews/gator-permissions-controller@4.0.0-preview-1614749c0
@metamask-previews/geolocation-controller@0.1.2-preview-1614749c0
@metamask-previews/json-rpc-engine@10.2.4-preview-1614749c0
@metamask-previews/json-rpc-middleware-stream@8.0.8-preview-1614749c0
@metamask-previews/keyring-controller@25.2.0-preview-1614749c0
@metamask-previews/logging-controller@8.0.1-preview-1614749c0
@metamask-previews/message-manager@14.1.1-preview-1614749c0
@metamask-previews/messenger@1.1.1-preview-1614749c0
@metamask-previews/messenger-cli@0.2.0-preview-1614749c0
@metamask-previews/money-account-balance-service@0.2.0-preview-1614749c0
@metamask-previews/money-account-controller@0.1.0-preview-1614749c0
@metamask-previews/money-account-upgrade-controller@1.2.0-preview-1614749c0
@metamask-previews/multichain-account-service@8.0.1-preview-1614749c0
@metamask-previews/multichain-api-middleware@2.0.0-preview-1614749c0
@metamask-previews/multichain-network-controller@3.0.6-preview-1614749c0
@metamask-previews/multichain-transactions-controller@7.0.4-preview-1614749c0
@metamask-previews/name-controller@9.1.1-preview-1614749c0
@metamask-previews/network-controller@30.0.1-preview-1614749c0
@metamask-previews/network-enablement-controller@5.0.2-preview-1614749c0
@metamask-previews/notification-services-controller@23.1.0-preview-1614749c0
@metamask-previews/passkey-controller@1.0.0-preview-1614749c0
@metamask-previews/permission-controller@12.3.0-preview-1614749c0
@metamask-previews/permission-log-controller@5.1.0-preview-1614749c0
@metamask-previews/perps-controller@4.0.0-preview-1614749c0
@metamask-previews/phishing-controller@17.1.1-preview-1614749c0
@metamask-previews/polling-controller@16.0.4-preview-1614749c0
@metamask-previews/preferences-controller@23.1.0-preview-1614749c0
@metamask-previews/profile-metrics-controller@3.1.3-preview-1614749c0
@metamask-previews/profile-sync-controller@28.0.2-preview-1614749c0
@metamask-previews/ramps-controller@13.2.0-preview-1614749c0
@metamask-previews/rate-limit-controller@7.0.1-preview-1614749c0
@metamask-previews/react-data-query@0.2.0-preview-1614749c0
@metamask-previews/remote-feature-flag-controller@4.2.0-preview-1614749c0
@metamask-previews/sample-controllers@4.0.4-preview-1614749c0
@metamask-previews/seedless-onboarding-controller@9.1.0-preview-1614749c0
@metamask-previews/selected-network-controller@26.1.0-preview-1614749c0
@metamask-previews/shield-controller@5.1.1-preview-1614749c0
@metamask-previews/signature-controller@39.2.0-preview-1614749c0
@metamask-previews/snap-account-service@0.0.0-preview-1614749c0
@metamask-previews/social-controllers@2.2.0-preview-1614749c0
@metamask-previews/storage-service@1.0.1-preview-1614749c0
@metamask-previews/subscription-controller@6.1.2-preview-1614749c0
@metamask-previews/transaction-controller@65.0.0-preview-1614749c0
@metamask-previews/transaction-pay-controller@20.0.0-preview-1614749c0
@metamask-previews/user-operation-controller@41.2.0-preview-1614749c0

Copy link
Copy Markdown
Member

@Gudahtt Gudahtt left a comment

Choose a reason for hiding this comment

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

LGTM!

@mcmire mcmire added this pull request to the merge queue Apr 29, 2026
@github-merge-queue github-merge-queue Bot removed this pull request from the merge queue due to failed status checks Apr 29, 2026
@mcmire mcmire added this pull request to the merge queue Apr 29, 2026
@github-merge-queue github-merge-queue Bot removed this pull request from the merge queue due to failed status checks Apr 29, 2026
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

2 participants