Skip to content

Commit

Permalink
Fix #20930 - Prevent Firefox start failure by awaiting startUISync ev…
Browse files Browse the repository at this point in the history
…ent (#20992)

* Fix #20930 - Prevent Firefox start failure by awaiting startUISync event

* Update documentation
  • Loading branch information
darkwing authored Sep 21, 2023
1 parent 31262a0 commit 48184fe
Show file tree
Hide file tree
Showing 2 changed files with 8 additions and 2 deletions.
2 changes: 1 addition & 1 deletion app/scripts/metamask-controller.js
Original file line number Diff line number Diff line change
Expand Up @@ -3211,7 +3211,7 @@ export default class MetamaskController extends EventEmitter {
}

_startUISync() {
// Message startUISync is used in MV3 to start syncing state with UI
// Message startUISync is used to start syncing state with UI
// Sending this message after login is completed helps to ensure that incomplete state without
// account details are not flushed to UI.
this.emit('startUISync');
Expand Down
8 changes: 7 additions & 1 deletion app/scripts/ui.js
Original file line number Diff line number Diff line change
Expand Up @@ -257,7 +257,13 @@ async function start() {
extensionPort.onMessage.addListener(messageListener);
extensionPort.onDisconnect.addListener(resetExtensionStreamAndListeners);
} else {
initializeUiWithTab(activeTab);
const messageListener = async (message) => {
if (message?.data?.method === 'startUISync') {
initializeUiWithTab(activeTab);
extensionPort.onMessage.removeListener(messageListener);
}
};
extensionPort.onMessage.addListener(messageListener);
}

function initializeUiWithTab(tab) {
Expand Down

0 comments on commit 48184fe

Please sign in to comment.