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