Make reject filter download abortable

This commit is contained in:
SukkaW
2023-07-13 22:45:30 +08:00
parent 685427472b
commit 2c4d5a33a5
4 changed files with 35 additions and 3 deletions

View File

@@ -133,11 +133,19 @@ async function processFilterRules(filterRulesUrl, fallbackUrls, includeThirdPart
let filterRules;
try {
const controller = new AbortController();
const signal = controller.signal;
/** @type string[] */
filterRules = (
await Promise.any(
[filterRulesUrl, ...(fallbackUrls || [])].map(
async url => (await fetchWithRetry(url)).text()
url => fetchWithRetry(url, { signal })
.then(r => r.text())
.then(text => {
controller.abort();
return text;
})
)
)
).split('\n').map(line => line.trim());