MetaMask / MetaMask/metamask-extension
Provide Failsafe Mechanism to restore accounts from faulty state persistence
- Dominant language
- TypeScript
- Stars
- 13.2k
- Forks
- 5.6k
- Avg merge
- 2d 5h
- Merged PRs (30d)
- 451
Description
In several issues reported in the extension codebase, users are experiencing issues loading MetaMask after some time, wherein the user's persisted state has either moved from its expected location or changed file format unexpectedly. We have not yet isolated the cases under which the storage file changes, but we can, at the very least, persist the user's vault to a secondary storage location in the browser. Using the browser's `localStorage` API, we can store a copy of the vault that is updated only when it changes.
On initialization of the application we can detect missing state and pull the vault into the default state generated by MetaMask on a new install. Users who have reported this issue on Chrome experience immediately drop into the onboarding flow as if they are a new user. This means that chrome, when not able to locate state files, simply provides us with not state. On firefox the situation is more dire, as the failure is happening in the Firefox internal code when loading the state from the storage system. We may need to bypass the actual error (using try/catch or something?) to allow the restore to work.
In any event, doing this doesn't fix the underlying problem of state being corrupted or unable to load in the browser, but it does prevent the user from losing their accounts.
Contributor guide
Research direction
Start by tracing application initialization and the existing persisted-state loading path, then review how the onboarding flow handles missing state. Investigate the browser localStorage API and the Chrome and Firefox failure behavior described here. Done means a recoverable vault copy is updated on change and can restore missing state without exposing users to a new-install flow.
Written by the indexing model from the issue text.
Assessment
- Tech stack
- typescript
- Domain
- frontend, web-dev
- Issue type
- Feature
- Difficulty
- 4/5
- Estimated time
- 3-5 days
- Activity status
- Stale
- Clarity
- Mostly clear
- Newbie friendliness
- 35/100