Skip to content

fix: Ensure that network client ID is updated before use#4801

Merged
FrederikBolding merged 2 commits intomainfrom
fb/fix-edge-case-in-network-deletion
Oct 16, 2024
Merged

fix: Ensure that network client ID is updated before use#4801
FrederikBolding merged 2 commits intomainfrom
fb/fix-edge-case-in-network-deletion

Conversation

@FrederikBolding
Copy link
Member

Explanation

This PR fixes a rare problem that would occur when deleting a network after a proxy in SelectedNetworkController has been garbage collected. When this happens, getProviderAndBlockTracker will fail to find the old network client ID and thus updating the network client ID for the domain will fail.

This could be reproduced in an E2E test that would only fail on this branch: MetaMask/metamask-extension#27306 which enables initialConnections for a preinstalled Snap. initialConnections adds a permission for an origin to connect to a Snap which causes the SelectedNetworkController to register the domain. My theory is that since the user has not accessed the origin in question yet, the proxy may not be used and may be garbage collected. If a network is deleted following that, an error occurs.

Changelog

@metamask/selected-network-controller

  • Fixed: Ensure that network client ID is updated before using it

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 highlighted breaking changes using the "BREAKING" category above as appropriate
  • I've prepared draft pull requests for clients and consumer packages to resolve any breaking changes

@FrederikBolding FrederikBolding requested review from a team as code owners October 16, 2024 12:35
Copy link
Contributor

@adonesky1 adonesky1 left a comment

Choose a reason for hiding this comment

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

LGTM

@FrederikBolding FrederikBolding force-pushed the fb/fix-edge-case-in-network-deletion branch from f33f469 to 8ef7b25 Compare October 16, 2024 15:57
@FrederikBolding FrederikBolding merged commit 16d37a7 into main Oct 16, 2024
@FrederikBolding FrederikBolding deleted the fb/fix-edge-case-in-network-deletion branch October 16, 2024 16:01
@adonesky1 adonesky1 mentioned this pull request Oct 17, 2024
adonesky1 added a commit that referenced this pull request Oct 17, 2024
# Release v222.0.0

## @metamask/selected-network-controller

## [18.0.2]

### Fixed

- Ensure that networkClientID is updated in domains state before
attempting to fetch its network proxy
([#4801](#4801))
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