mirror of
https://github.com/SukkaW/Surge.git
synced 2025-12-16 03:00:34 +08:00
Compare commits
No commits in common. "b46ff52e1c8728d868a532d4138aa9fc3fd78d44" and "31fb27cc824f893144857101bee550a2c066f63f" have entirely different histories.
b46ff52e1c
...
31fb27cc82
@ -8,9 +8,14 @@ import { AdGuardFilterIgnoreUnsupportedLinesStream } from './parse-filter/filter
|
|||||||
import { appendArrayInPlace } from 'foxts/append-array-in-place';
|
import { appendArrayInPlace } from 'foxts/append-array-in-place';
|
||||||
|
|
||||||
import { newQueue } from '@henrygd/queue';
|
import { newQueue } from '@henrygd/queue';
|
||||||
import { AbortError } from 'foxts/abort-error';
|
|
||||||
|
|
||||||
const reusedCustomAbortError = new AbortError();
|
// eslint-disable-next-line sukka/unicorn/custom-error-definition -- typescript is better
|
||||||
|
class CustomAbortError extends Error {
|
||||||
|
public readonly name = 'AbortError';
|
||||||
|
public readonly digest = 'AbortError';
|
||||||
|
}
|
||||||
|
|
||||||
|
const reusedCustomAbortError = new CustomAbortError();
|
||||||
|
|
||||||
const queue = newQueue(16);
|
const queue = newQueue(16);
|
||||||
|
|
||||||
|
|||||||
@ -18,7 +18,6 @@ import { inspect } from 'node:util';
|
|||||||
import path from 'node:path';
|
import path from 'node:path';
|
||||||
import fs from 'node:fs';
|
import fs from 'node:fs';
|
||||||
import { CACHE_DIR } from '../constants/dir';
|
import { CACHE_DIR } from '../constants/dir';
|
||||||
import { isAbortErrorLike } from 'foxts/abort-error';
|
|
||||||
|
|
||||||
if (!fs.existsSync(CACHE_DIR)) {
|
if (!fs.existsSync(CACHE_DIR)) {
|
||||||
fs.mkdirSync(CACHE_DIR, { recursive: true });
|
fs.mkdirSync(CACHE_DIR, { recursive: true });
|
||||||
@ -167,8 +166,13 @@ export async function $$fetch(url: string, init: RequestInit = defaultRequestIni
|
|||||||
|
|
||||||
return res;
|
return res;
|
||||||
} catch (err: unknown) {
|
} catch (err: unknown) {
|
||||||
if (isAbortErrorLike(err)) {
|
if (typeof err === 'object' && err !== null && 'name' in err) {
|
||||||
console.log(picocolors.gray('[fetch abort]'), url);
|
if ((
|
||||||
|
err.name === 'AbortError'
|
||||||
|
|| ('digest' in err && err.digest === 'AbortError')
|
||||||
|
)) {
|
||||||
|
console.log(picocolors.gray('[fetch abort]'), url);
|
||||||
|
}
|
||||||
} else {
|
} else {
|
||||||
console.log(picocolors.gray('[fetch fail]'), url, { name: (err as any).name }, err);
|
console.log(picocolors.gray('[fetch fail]'), url, { name: (err as any).name }, err);
|
||||||
}
|
}
|
||||||
@ -191,8 +195,13 @@ export async function requestWithLog(url: string, opt?: Parameters<typeof undici
|
|||||||
|
|
||||||
return res;
|
return res;
|
||||||
} catch (err: unknown) {
|
} catch (err: unknown) {
|
||||||
if (isAbortErrorLike(err)) {
|
if (typeof err === 'object' && err !== null && 'name' in err) {
|
||||||
console.log(picocolors.gray('[fetch abort]'), url);
|
if ((
|
||||||
|
err.name === 'AbortError'
|
||||||
|
|| ('digest' in err && err.digest === 'AbortError')
|
||||||
|
)) {
|
||||||
|
console.log(picocolors.gray('[fetch abort]'), url);
|
||||||
|
}
|
||||||
} else {
|
} else {
|
||||||
console.log(picocolors.gray('[fetch fail]'), url, { name: (err as any).name }, err);
|
console.log(picocolors.gray('[fetch fail]'), url, { name: (err as any).name }, err);
|
||||||
}
|
}
|
||||||
|
|||||||
@ -5101,6 +5101,3 @@ static.underhentai.net
|
|||||||
covers.openlibrary.org
|
covers.openlibrary.org
|
||||||
cdn.nodeimage.com
|
cdn.nodeimage.com
|
||||||
.digikeyassets.com
|
.digikeyassets.com
|
||||||
.storage.boilerplate.com
|
|
||||||
api-cdn.shutterstock.com
|
|
||||||
server.arcgisonline.com
|
|
||||||
|
|||||||
Loading…
x
Reference in New Issue
Block a user