Skip to content

Conversation

@cryptodev-2s
Copy link
Contributor

@cryptodev-2s cryptodev-2s commented Jan 14, 2026

Explanation

Connects NetworkController to ConnectivityController to suppress RPC endpoint error events when the user is offline.

Changes

  • Suppress NetworkController:rpcEndpointUnavailable and NetworkController:rpcEndpointDegraded events when connectivity status is offline

Breaking Changes

  • BREAKING: NetworkController now requires ConnectivityController:getState action handler to be registered on the messenger
    • The action handler must return an object with a connectivityStatus property ('online' or 'offline')
    • The action must be delegated from the root messenger to the NetworkControllerMessenger

References

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

Makes RPC behavior offline-aware and updates dependencies/types.

  • Add dependency on @metamask/connectivity-controller; update messenger to allow ConnectivityController:getState
  • Pass isOffline into RPC services; in RpcService, skip retries and circuit-breaker triggers when offline
  • Suppress NetworkController:rpcEndpointUnavailable and NetworkController:rpcEndpointDegraded events when offline
  • Update tests to assert no retries and suppressed events offline; extend integration test to delegate ConnectivityController:getState
  • Update README dependency graph, tsconfig references, package.json, and yarn.lock
  • Document breaking requirement to register and delegate ConnectivityController:getState in CHANGELOG

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

@cryptodev-2s cryptodev-2s requested a review from mcmire January 14, 2026 15:46
@cryptodev-2s cryptodev-2s self-assigned this Jan 14, 2026
@cryptodev-2s
Copy link
Contributor Author

@metamaskbot publish-preview

@cryptodev-2s cryptodev-2s force-pushed the feature/connect-network-controller-to-connectivity branch from 1a810fe to b590b43 Compare January 14, 2026 15:47
@cryptodev-2s cryptodev-2s changed the title feat(network-controller): connect NetworkController to ConnectivityCo… feat(network-controller): connect NetworkController to ConnectivityController Jan 14, 2026
@cryptodev-2s cryptodev-2s marked this pull request as ready for review January 14, 2026 15:47
@cryptodev-2s cryptodev-2s requested review from a team as code owners January 14, 2026 15:47
@cryptodev-2s cryptodev-2s force-pushed the feature/connect-network-controller-to-connectivity branch from b590b43 to 1bdba27 Compare January 14, 2026 18:34
throw new Error('Could not make request to endpoint.');
}

const connectivityState = messenger.call(
Copy link
Contributor

@mcmire mcmire Jan 14, 2026

Choose a reason for hiding this comment

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

It's fine to add this check just to be absolutely sure that these events aren't published. But I wonder if we should add similar logic to RpcService as well? If the user is offline, and a "connection error" is thrown while making a request, then the request should not be retried. If we do this, then the onDegraded or onBreak callbacks within RpcService should never be called, and therefore neither NetworkController:rpcEndpointDegraded nor NetworkController:rpcEndpointUnavailable should be published.

Copy link
Contributor Author

Choose a reason for hiding this comment

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

@mcmire I made an update here e3d5f1f is that what you had in mind ?

@cryptodev-2s cryptodev-2s force-pushed the feature/connect-network-controller-to-connectivity branch from 1bdba27 to 753eb65 Compare January 14, 2026 21:07
@cryptodev-2s cryptodev-2s requested a review from a team as a code owner January 14, 2026 21:07
@cryptodev-2s cryptodev-2s force-pushed the feature/connect-network-controller-to-connectivity branch 2 times, most recently from 5c3f070 to 35be87b Compare January 14, 2026 21:26
@cryptodev-2s
Copy link
Contributor Author

@metamaskbot publish-preview

@cryptodev-2s cryptodev-2s force-pushed the feature/connect-network-controller-to-connectivity branch 3 times, most recently from 3d671df to be34729 Compare January 14, 2026 21:59
@cryptodev-2s
Copy link
Contributor Author

@metamaskbot publish-preview

…ntroller

- Add ConnectivityController:getState action handler requirement
- Suppress rpcEndpointUnavailable and rpcEndpointDegraded events when offline
- Update NetworkController to check connectivity status before publishing events
- Add tests for offline event suppression
…fline

- Add isOffline check to RpcService retry filter policy to prevent retries when offline
- Suppress rpcEndpointUnavailable and rpcEndpointDegraded events when offline
- Add tests to verify retries don't happen when offline
- Add tests to verify events are suppressed when offline
- Update CHANGELOG with breaking change documentation
@cryptodev-2s cryptodev-2s force-pushed the feature/connect-network-controller-to-connectivity branch from e3d5f1f to d59bf85 Compare January 14, 2026 23:14
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.

3 participants