[mv3] Fix force-reloading repeatedly when erroring at load time

Related issue:
https://github.com/uBlockOrigin/uBOL-home/issues/234
This commit is contained in:
Raymond Hill 2024-11-19 13:16:56 -05:00
parent 2f2f383c1b
commit f3486275e9
No known key found for this signature in database
GPG Key ID: 25E1490B761470C2
1 changed files with 13 additions and 7 deletions

View File

@ -35,7 +35,7 @@ import {
adminRead, adminRead,
browser, browser,
dnr, dnr,
localRead, localWrite, localRead, localRemove, localWrite,
runtime, runtime,
windows, windows,
} from './ext.js'; } from './ext.js';
@ -407,13 +407,19 @@ async function start() {
// https://github.com/uBlockOrigin/uBOL-home/issues/199 // https://github.com/uBlockOrigin/uBOL-home/issues/199
// Force a restart of the extension once when an "internal error" occurs // Force a restart of the extension once when an "internal error" occurs
start().then(( ) => { start().then(( ) => {
localWrite({ goodStart: true }); localRemove('goodStart');
return false;
}).catch(reason => { }).catch(reason => {
console.trace(reason); console.trace(reason);
localRead('goodStart').then((bin = {}) => { if ( process.wakeupRun ) { return; }
if ( bin.goodStart === false ) { return; } return localRead('goodStart').then(goodStart => {
localWrite({ goodStart: false }).then(( ) => { if ( goodStart === false ) {
localRemove('goodStart');
return false;
}
return localWrite('goodStart', false).then(( ) => true);
});
}).then(restart => {
if ( restart !== true ) { return; }
runtime.reload(); runtime.reload();
}); });
});
});