Skip to content

Commit

Permalink
error resilience
Browse files Browse the repository at this point in the history
'work' (show popup) even if serviceworker coms is failing
  • Loading branch information
ttyridal committed Sep 15, 2023
1 parent 61ab039 commit b05ce53
Showing 1 changed file with 10 additions and 6 deletions.
16 changes: 10 additions & 6 deletions ext/webextension/src/browser_action/main_popup.js
Original file line number Diff line number Diff line change
Expand Up @@ -60,10 +60,14 @@ const runtimeSendMessage = (typeof browser !== 'undefined' ?
browser.runtime.sendMessage :
(msg) => new Promise(suc => chrome.runtime.sendMessage(msg, suc)));

function state_or_masterkey_get(use_pass_store) {
return runtimeSendMessage({action: 'masterkey_get',
use_pass_store})
.catch(err=>{ console.log("BUG!",err); });
async function state_or_masterkey_get(use_pass_store) {
let res = await runtimeSendMessage({action: 'masterkey_get', use_pass_store});
if (res === undefined || chrome.runtime.lastError) {
console.error("runtimeSendMessage failed", chrome.runtime.lastError.message);
ui.user_warn("BUG! Failed backend communication");
return {};
}
return res;
}

function masterkey_set(masterkey, nosave) {
Expand Down Expand Up @@ -370,6 +374,7 @@ async function windowOnLoad() {
sitestore = new SiteStore(config.use_sync ? chrome.storage.sync : chrome.storage.local);
await psl.waitTableReady();

ui.clear_warning();
let data = {};
if (v.passwdtimeout!=0 || v.pass_store) {
data = await state_or_masterkey_get(v.pass_store);
Expand All @@ -381,12 +386,11 @@ async function windowOnLoad() {
e.target = "_blank";
e.textContent = "Help?";
data.masterkey=undefined;
} else {
ui.clear_warning();
}

if (!data.mpwstate && !(data.masterkey && config.username))
data = await getUserNameAndPassFromUser();
ui.clear_warning();

setTimeout(()=>{ resolve_mpw(data);}, 1); // do later so page paints as fast as possible

Expand Down

0 comments on commit b05ce53

Please sign in to comment.