From 60bfdffdd65f764e88091d2dbbf7a7f2fe9163d0 Mon Sep 17 00:00:00 2001 From: Kendall Werts Date: Wed, 15 Jan 2020 14:46:52 -0600 Subject: [PATCH] fixed race condition while upgrading containers and site assignments. --- src/js/background/assignManager.js | 22 ++++++++++------------ src/js/background/identityState.js | 2 +- src/js/background/sync.js | 2 +- 3 files changed, 12 insertions(+), 14 deletions(-) diff --git a/src/js/background/assignManager.js b/src/js/background/assignManager.js index 8e82678..2655768 100644 --- a/src/js/background/assignManager.js +++ b/src/js/background/assignManager.js @@ -112,8 +112,6 @@ const assignManager = { return sites; }, - // TODOkmw: Change site assignment UUID - /* * Looks for abandoned site assignments. If there is no identity with * the site assignment's userContextId (cookieStoreId), then the assignment @@ -133,15 +131,15 @@ const assignManager = { await this.remove(configKey.replace(/^siteContainerMap@@_/, "https://")); continue; } - const updatedSideAssignment = macConfigs[configKey]; - if (!macConfigs[configKey].identityMacAddonUUID) { - await this.set( - configKey.replace(/^siteContainerMap@@_/, "https://"), - updatedSideAssignment, - false, - false - ); - } + const updatedSiteAssignment = macConfigs[configKey]; + updatedSiteAssignment.identityMacAddonUUID = + await identityState.lookupMACaddonUUID(match.cookieStoreId); + await this.set( + configKey, + updatedSiteAssignment, + false, + false + ); } } @@ -168,7 +166,7 @@ const assignManager = { // We return here so the confirm page can load the tab when exempted async _exemptTab(m) { const pageUrl = m.pageUrl; - this.storageArea.setExempted(pageUrl, m.tabId); + await this.storageArea.setExempted(pageUrl, m.tabId); return true; }, diff --git a/src/js/background/identityState.js b/src/js/background/identityState.js index e1b281f..9ae8403 100644 --- a/src/js/background/identityState.js +++ b/src/js/background/identityState.js @@ -58,7 +58,7 @@ const identityState = { ); if (cookieStoreId === "firefox-default") continue; if (!match) { - this.remove(cookieStoreId); + await this.remove(cookieStoreId); continue; } if (!macConfigs[configKey].macAddonUUID) { diff --git a/src/js/background/sync.js b/src/js/background/sync.js index 48a6270..e33bf2c 100644 --- a/src/js/background/sync.js +++ b/src/js/background/sync.js @@ -148,7 +148,7 @@ const sync = { }, async errorHandledRunSync () { - sync.runSync().catch(async (error)=> { + await sync.runSync().catch( async (error)=> { console.error("Error from runSync", error); await sync.checkForListenersMaybeAdd(); });