You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
fix: NotificationServicesController - check keyring state when using stateChange event (#5731)
## Explanation
Uncovered on extension. I haven't pieced all the moving parts together
but notifications essentially perform:
- Listens to `KeyringController:stateChange` events
- When receiving an event we perform a `KeyringController:withKeyring`
action.
Somewhere above (or potentially another controller?) will then fire
another `KeyringController:stateChange`, and we have a infinite loop
preventing other redux or state updates.
Now we will check the size of the keyring to better assume if accounts
have been added or removed.
## References
<!--
Are there any issues that this pull request is tied to?
Are there other links that reviewers should consult to understand these
changes better?
Are there client or consumer pull requests to adopt any breaking
changes?
For example:
* Fixes #12345
* Related to #67890
-->
## Changelog
<!--
THIS SECTION IS NO LONGER NEEDED.
The process for updating changelogs has changed. Please consult the
"Updating changelogs" section of the Contributing doc for more.
-->
## Checklist
- [x] I've updated the test suite for new or updated code as appropriate
- [x] I've updated documentation (JSDoc, Markdown, etc.) for new or
updated code as appropriate
- [x] I've communicated my changes to consumers by [updating changelogs
for packages I've
changed](https://github.com/MetaMask/core/tree/main/docs/contributing.md#updating-changelogs),
highlighting breaking changes as necessary
- [x] I've prepared draft pull requests for clients and consumer
packages to resolve any breaking changes
Copy file name to clipboardExpand all lines: packages/notification-services-controller/CHANGELOG.md
+7
Original file line number
Diff line number
Diff line change
@@ -11,6 +11,13 @@ and this project adheres to [Semantic Versioning](https://semver.org/spec/v2.0.0
11
11
12
12
- Bump `@metamask/base-controller` from ^8.0.0 to ^8.0.1 ([#5722](https://github.com/MetaMask/core/pull/5722))
13
13
14
+
### Fixed
15
+
16
+
- add a check inside the `KeyringController:stateChange` subscription inside `NotificationServicesController` to prevent infinite updates ([#5731](https://github.com/MetaMask/core/pull/5731))
17
+
- As we invoke a `KeyringController:withKeyring` inside the `KeyringController:stateChange` event subscription,
18
+
we are causing many infinite updates which block other controllers from performing state updates.
19
+
- We now check the size of keyrings from the `KeyringController:stateChange` to better assume when keyrings have been added
Copy file name to clipboardExpand all lines: packages/notification-services-controller/src/NotificationServicesController/NotificationServicesController.test.ts
Copy file name to clipboardExpand all lines: packages/notification-services-controller/src/NotificationServicesController/NotificationServicesController.ts
+13-2
Original file line number
Diff line number
Diff line change
@@ -16,6 +16,7 @@ import {
16
16
typeKeyringControllerUnlockEvent,
17
17
typeKeyringControllerWithKeyringAction,
18
18
KeyringTypes,
19
+
typeKeyringControllerState,
19
20
}from'@metamask/keyring-controller';
20
21
importtype{
21
22
AuthenticationController,
@@ -501,8 +502,12 @@ export default class NotificationServicesController extends BaseController<
0 commit comments