Self-reload extension on startup error
What is this about?
When the user manually updates the extension, they are almost guaranteed to get an error on startup because of chromium issue:
Background connection unresponsive
Based on existing cases, reloading the extension solves this issue in 100% of cases, and since this is the majority of our "infinite spinner" events - we want to implement a workaround and not wait for the chromium fix
Possible solution 1: When this error is detected on startup - catch it and immediately reload the extension Challenge: To make sure we are not introducing an infinite reload loop in place of an infinite spinner
Possible solution 2: Outlined in this thread: https://consensys.slack.com/archives/CBHSSFEN5/p1756898354877439 0. track all connected ports in a Set
- first, have the SW tell all connected ports to stop talking to it; and make sure they don't try to reconnect (I deleted this code recently, but I suspect that I'll need to add it back, as I've recently saw the old reconnection logic being used via someone's logs)
- disconnect all Ports
- wait 50ms
- run chrome.runtime.reload();
TODO:
- Investigate if either of the solutions are feasible, starting with 2 - or suggest an alternative
- Implement the chosen solution
Actual solution: Catch chrome event "The app was updated" and always reload once after it happens
Scenario
No response
Design
No response
Technical Details
No response
Threat Modeling Framework
No response
Acceptance Criteria
No response
Stakeholder review needed before the work gets merged
- [ ] Engineering (needed in most cases)
- [ ] Design
- [ ] Product
- [ ] QA (automation tests are required to pass before merging PRs but not all changes are covered by automation tests - please review if QA is needed beyond automation tests)
- [ ] Security
- [ ] Legal
- [ ] Marketing
- [ ] Management (please specify)
- [ ] Other (please specify)
References
No response
https://github.com/MetaMask/metamask-extension/issues/36248