1
0
mirror of https://github.com/gorhill/uBlock.git synced 2024-11-16 15:33:38 +01:00

Fix potential failure to unregister scriptlet

In Firefox-specific contentScripts API used to register
scriptlets. This could potentially occurs when there are
registrations pending during a reload of filter lists.
This commit is contained in:
Raymond Hill 2024-09-14 09:31:22 -04:00
parent 41d49921c8
commit f936dfa648
No known key found for this signature in database
GPG Key ID: 25E1490B761470C2

View File

@ -61,6 +61,7 @@ const contentScriptRegisterer = new (class {
runAt: 'document_start',
}).then(handle => {
this.hostnameToDetails.set(hostname, { handle, code });
return handle;
}).catch(( ) => {
this.hostnameToDetails.delete(hostname);
});
@ -94,7 +95,9 @@ const contentScriptRegisterer = new (class {
}
unregisterHandle(handle) {
if ( handle instanceof Promise ) {
handle.then(handle => { handle.unregister(); });
handle.then(handle => {
if ( handle ) { handle.unregister(); }
});
} else {
handle.unregister();
}