core icon indicating copy to clipboard operation
core copied to clipboard

[network-controller] Prevent inconsistent state during switch

Open Gudahtt opened this issue 1 year ago • 2 comments

When the NetworkController switches networks, the state changes 3 times: once to update providerConfig, once to update the network metadata (e.g. the network status), and once to update the selectedClientId. In between these changes, the NetworkController state will be inconsistent (providerConfig will not match the selectedClientId, and the network status will be stale). These state changes are all synchronous, they don't depend on any network requests (the lookup step comes later).

We should update the NetworkController to make a single state change, rather than three. This would prevent the state from being inconsistent.

Gudahtt avatar Mar 28 '24 17:03 Gudahtt

The lookup step makes this tricky because that can take a long time to resolve (if the network is unreachable). We want switching networks to be quick and responsive for users.

Maybe we should handle lookups separately from switching. e.g. trigger them in a way that doesn't block the setActiveNetwork call.

Gudahtt avatar Jun 25 '24 19:06 Gudahtt

We believe this is fixed now due to the changes with the NetworkController.

desi avatar Sep 26 '24 15:09 desi