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 = {}) {
if ( useLists.promise !== null ) {
throw new Error('Pending useLists() operation');
}
// Remove all filters
snfe.reset();
@ -174,13 +178,17 @@ async function useLists(lists, options = {}) {
promises.push(promise.then(list => consumeList(list)));
}
await Promise.all(promises);
useLists.promise = Promise.all(promises);
await useLists.promise;
useLists.promise = null;
// Commit changes
snfe.freeze();
snfe.optimize();
}
useLists.promise = null;
/******************************************************************************/
class MockStorage {