1
0
mirror of https://github.com/gorhill/uBlock.git synced 2024-10-04 16:47:15 +02:00

Throw when useLists() called concurrently

Related feedback:
- https://github.com/gorhill/uBlock/pull/3836/files#r690687656
This commit is contained in:
Raymond Hill 2021-08-17 16:57:39 -04:00
parent 60e254608a
commit 7a5c4e9547
No known key found for this signature in database
GPG Key ID: 25E1490B761470C2

View File

@ -146,6 +146,10 @@ function compileList({ name, raw }, compiler, writer, options = {}) {
/******************************************************************************/ /******************************************************************************/
async function useLists(lists, options = {}) { async function useLists(lists, options = {}) {
if ( useLists.promise !== null ) {
throw new Error('Pending useLists() operation');
}
// Remove all filters // Remove all filters
snfe.reset(); snfe.reset();
@ -174,13 +178,17 @@ async function useLists(lists, options = {}) {
promises.push(promise.then(list => consumeList(list))); promises.push(promise.then(list => consumeList(list)));
} }
await Promise.all(promises); useLists.promise = Promise.all(promises);
await useLists.promise;
useLists.promise = null;
// Commit changes // Commit changes
snfe.freeze(); snfe.freeze();
snfe.optimize(); snfe.optimize();
} }
useLists.promise = null;
/******************************************************************************/ /******************************************************************************/
class MockStorage { class MockStorage {