Skip to content

Gracefully handle invalid selectedNetworkClientId upon NetworkController initialization #5739

New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Open
mcmire opened this issue Apr 30, 2025 · 1 comment · May be fixed by #5851
Open

Gracefully handle invalid selectedNetworkClientId upon NetworkController initialization #5739

mcmire opened this issue Apr 30, 2025 · 1 comment · May be fixed by #5851
Assignees

Comments

@mcmire
Copy link
Contributor

mcmire commented Apr 30, 2025

NetworkController should prevent selectedNetworkClientId from being invalid whenever state is updated. In fact, it goes one step further: upon initialization, it will immediately throw an error if selectedNetworkClientId is invalid.

Regrettably, this does not lead to a great user experience. If this occurs, we should instead reset selectedNetworkClientId to a reasonable default chain (Mainnet would work, but we would have to account for if Mainnet is not present). We should also report this fact to Sentry.

This solution was mentioned in the discussion for incident 1051.

Acceptance Criteria

  • Upon initialization, if it detects that selectedNetworkClientId does not refer to an RPC endpoint, NetworkController resets the property to a reasonable default chain and reports the problem to Sentry.
@mcmire
Copy link
Contributor Author

mcmire commented May 2, 2025

This would also fix MetaMask/metamask-extension#28152.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Projects
None yet
Development

Successfully merging a pull request may close this issue.

2 participants