-
-
Notifications
You must be signed in to change notification settings - Fork 1.1k
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
fix: breaking selector due to missing controller state #12375
base: main
Are you sure you want to change the base?
Conversation
the selector is trying to access some engine state that is removed at build time through code-fences. Long term - we need to investigate and ensure that the UI is not calling the selectors.
CLA Signature Action: All authors have signed the CLA. You may need to manually re-run the blocking PR check if it doesn't pass in a few minutes. |
Bitrise❌❌❌ Commit hash: 4540de3 Note
Tip
|
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
LGTM
@Prithpal-Sooriya can you show manual confirmation this has fixed the issue? |
…tamask-mobile into hotfix/fix-breaking-selector
825d2a4
state?.engine?.backgroundState?.UserStorageController ?? | ||
UserStorageController.defaultState; |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
This is the main fix for the missing controller state.
It is really odd that the controller state is missing sometimes. I have a hypothesis, but it is hard to prove.
Maybe we should have it as mobile best practice to "distrust controller state", or maybe at the type level make the controllers partial/optional (but this would be a large breaking change).
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I think I prefer this selector default state approach instead of migrations, as the redux state should do a second re-hydration once the engine has been initialised. We can then keep migrations only for state patches/fixes.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
The easiest way to proof this is creating a migration for testing purposes and delete the UserStorageController data if exists, wdyt?
if (!isNotificationsFeatureEnabled()) { | ||
return; | ||
} |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
All these other changes to hooks is to ensure we aren't unintentionally calling these hooks when the feature is off.
@@ -3583,188 +3583,8 @@ exports[`SecuritySettings should render correctly 1`] = ` | |||
swipeDirection="down" | |||
swipeThreshold={100} | |||
transparent={true} | |||
visible={true} | |||
> | |||
<View |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Snapshot change as we are now not calling any notification hooks during a side effect.
TODO: I want us to clean up/remove this effect:
metamask-mobile/app/components/Views/Settings/SecuritySettings/SecuritySettings.tsx
Lines 209 to 216 in 35c51df
useEffect(() => { | |
const triggerCascadeBasicFunctionalityDisable = async () => { | |
if (!isBasicFunctionalityEnabled) { | |
isNotificationEnabled && (await disableNotifications()); | |
isProfileSyncingEnabled && (await disableProfileSyncing()); | |
} | |
}; | |
triggerCascadeBasicFunctionalityDisable(); |
I don't want side effects to cascade the updates for basic functionality (especially since this can be re-invoked from dependency changes). Instead I want this to be done during the basic functionality switch-off.
Bitrise✅✅✅ Commit hash: 344002f Note
|
@sethkfman I've attached a recording for a before and after the changes. I've also sneaked in some other changes to ensure notification hooks are not called when the feature is disabled. |
Quality Gate passedIssues Measures |
Description
The selector is trying to access some engine state that is removed at build time through code-fences.
This fix ensures that the selectors are using the engine state or default to the controllers default state.
Long term - we need to investigate and ensure that the UI is not calling the selectors.
Related issues
Fixes: #11909
Manual testing steps
Screenshots/Recordings
Before / After Recording
https://www.loom.com/share/badc4b4cd3b0446486497973dcf337f6?sid=33bcfe23-c495-41bf-89f5-e57b4b72e3d2
I was not able to replicate the controller state being undefined/missing, so forced it to be undefined when testing.
Pre-merge author checklist
Pre-merge reviewer checklist