Skip to content
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 #15050 - MV3: Keep the user logged in when service worker restarts #15558

Merged
merged 46 commits into from
Nov 24, 2022

Conversation

darkwing
Copy link
Contributor

@darkwing darkwing commented Aug 11, 2022

Explanation

Currently, when the service worker restarts, the user gets logged out. This PR is the extension portion of the login fix. More details will be added as we get further along.

More Information

Depends on:

Manual Testing Steps

  • Start the extension in mv3 mode: yarn start:mv3
  • Login to MetaMask
  • Lock MetaMask
  • Log in again
  • Open the DevTools "Application" panel and kill the service worker (it will restart)
  • Execute actions that would require login without refreshing the page ("Create Account"), for example
  • See that you're still logged in, actions working correctly

Pre-Merge Checklist

  • PR template is filled out
  • IF this PR fixes a bug, a test that would have caught the bug has been added
  • PR is linked to the appropriate GitHub issue
  • PR has been added to the appropriate release Milestone

+ If there are functional changes:

  • Manual testing complete & passed
  • "Extension QA Board" label has been applied

@darkwing darkwing requested a review from a team as a code owner August 11, 2022 18:44
@darkwing darkwing requested a review from ryanml August 11, 2022 18:44
@github-actions
Copy link
Contributor

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.

@darkwing darkwing marked this pull request as draft August 11, 2022 18:52
@hilvmason hilvmason added the PR - P1 identifies PRs deemed priority for Extension team label Aug 15, 2022
@seaona
Copy link
Contributor

seaona commented Sep 22, 2022

I've noticed the following behaviors:

  1. If I have the extension full window open, and I wait +5min idle, MM does not logout
  2. If I don't have the extension full window open, and I wait +5min idle, MM does logout
  3. If I terminate the Service Worker manually, and have the extension full window open, MM does logout
  4. If I terminate the Service Worker manually, and I don't have the extension full window open, MM does logout

About 3 and 4, I am not completely sure this would ever happen in a real life scenario, as I don't think anyone would terminate the Service Worker manually. Just including it here in case we do need to consider it @darkwing @danjm

Behavior 2

mm-popup-idle.webm

Behavior 3

mm-full-manual-restart.webm

Behavior 4

mm-popup-manual-restart.webm

@seaona
Copy link
Contributor

seaona commented Oct 11, 2022

Some QA finding with last commits, I am getting the error Uncaught (in promise) Error: key is not extractable on the two Onboarding paths:

  • Onboarding Flow with Create Wallet
key-not-extractable-create.webm
  • Onboarding Flow with an Imported Account
key-not-extractable.webm

@darkwing darkwing force-pushed the mv3-login branch 4 times, most recently from b01909e to cacb5ca Compare October 19, 2022 19:00
@darkwing darkwing force-pushed the mv3-login branch 2 times, most recently from 9f689d7 to 20c066a Compare October 25, 2022 13:59
@seaona
Copy link
Contributor

seaona commented Oct 26, 2022

Started re-testing with the last changes and all previous errors mentioned above disappeared ⭐

I saw that the error vault.map is not a function is triggered after I log out and try to log in again. Not sure if it's something about my build or a global error for everyone.

Repro steps:

  1. Load MM
  2. Go to Create Wallet onboarding flow
  3. Lock MM
  4. Try to unlock MM -- see error on the UI
vault-map-notfunc.webm

@darkwing
Copy link
Contributor Author

Thanks @seaona ! I spotted this issue yesterday, as I was missing an await in the browser-passworder PR; this should be fixed. If you're still seeing it, I think it's because NPM is using cached information

yarn.lock Show resolved Hide resolved
@metamaskbot
Copy link
Collaborator

Builds ready [71a087f]
Page Load Metrics (2140 ± 87 ms)
PlatformPageMetricMin (ms)Max (ms)Average (ms)StandardDeviation (ms)MarginOfError (ms)
ChromeHomefirstPaint87135107147
domContentLoaded17522393212017182
load17532393214018287
domInteractive17522393212017182
Bundle size diffs [🚨 Warning! Bundle size has increased!]
  • background: 21911 bytes
  • ui: 15 bytes
  • common: 136 bytes

@metamaskbot
Copy link
Collaborator

Builds ready [c2577d9]
Page Load Metrics (2223 ± 113 ms)
PlatformPageMetricMin (ms)Max (ms)Average (ms)StandardDeviation (ms)MarginOfError (ms)
ChromeHomefirstPaint962004216411197
domContentLoaded176024942205231111
load176024942223235113
domInteractive176024942205231111
Bundle size diffs [🚨 Warning! Bundle size has increased!]
  • background: 22109 bytes
  • ui: 15 bytes
  • common: 136 bytes

@jpuri
Copy link
Contributor

jpuri commented Nov 23, 2022

@darkwing : Code changes look good and seems to work well 👍

I see one scenario breaking. If I login in MV2 and then start extension in MV3, I get this error while trying to login again using password:

Screenshot 2022-11-23 at 8 46 36 AM

@darkwing
Copy link
Contributor Author

I see one scenario breaking. If I login in MV2 and then start extension in MV3, I get this error while trying to login again using password

That should be the Ledger hardware wallet error, correct? That's a separate issue being worked on by the hardware wallets team.

@darkwing
Copy link
Contributor Author

Specifically, commenting out this line prevents the problem:

https://github.com/MetaMask/eth-ledger-bridge-keyring/blob/main/index.js#L40

The issue described isn't specific to or introduced by this PR.

Copy link
Member

@Gudahtt Gudahtt left a comment

Choose a reason for hiding this comment

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

LGTM!

@metamaskbot
Copy link
Collaborator

Builds ready [62fc4a2]
Page Load Metrics (2342 ± 170 ms)
PlatformPageMetricMin (ms)Max (ms)Average (ms)StandardDeviation (ms)MarginOfError (ms)
ChromeHomefirstPaint911141183221106
domContentLoaded172734872327363175
load172734872342354170
domInteractive172734872327363175
Bundle size diffs [🚨 Warning! Bundle size has increased!]
  • background: 22121 bytes
  • ui: 15 bytes
  • common: 136 bytes

@darkwing darkwing merged commit 266d7d9 into develop Nov 24, 2022
@darkwing darkwing deleted the mv3-login branch November 24, 2022 00:49
@github-actions github-actions bot locked and limited conversation to collaborators Nov 24, 2022
Sign up for free to subscribe to this conversation on GitHub. Already have an account? Sign in.
Labels
MV3 PR - P1 identifies PRs deemed priority for Extension team
Projects
None yet
Development

Successfully merging this pull request may close these issues.

MV3: Ensure user remains logged in after service work restart