mirror of
https://github.com/SukkaW/Surge.git
synced 2026-04-29 17:36:56 +08:00
Chore: increase download queue and enable HTTP/2
This commit is contained in:
@@ -12,7 +12,7 @@ import { AbortError } from 'foxts/abort-error';
|
|||||||
|
|
||||||
const reusedCustomAbortError = new AbortError();
|
const reusedCustomAbortError = new AbortError();
|
||||||
|
|
||||||
const queue = newQueue(16);
|
const queue = newQueue(18);
|
||||||
|
|
||||||
export async function fetchAssets(
|
export async function fetchAssets(
|
||||||
url: string, fallbackUrls: null | undefined | string[] | readonly string[],
|
url: string, fallbackUrls: null | undefined | string[] | readonly string[],
|
||||||
@@ -29,6 +29,7 @@ export async function fetchAssets(
|
|||||||
throw reusedCustomAbortError;
|
throw reusedCustomAbortError;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
if (controller.signal.aborted) {
|
if (controller.signal.aborted) {
|
||||||
throw reusedCustomAbortError;
|
throw reusedCustomAbortError;
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -24,9 +24,11 @@ if (!fs.existsSync(CACHE_DIR)) {
|
|||||||
fs.mkdirSync(CACHE_DIR, { recursive: true });
|
fs.mkdirSync(CACHE_DIR, { recursive: true });
|
||||||
}
|
}
|
||||||
|
|
||||||
const agent = new Agent({ allowH2: false });
|
const agent = new Agent({
|
||||||
|
allowH2: true
|
||||||
|
});
|
||||||
|
|
||||||
(agent.compose(
|
agent.compose(
|
||||||
interceptors.dns({
|
interceptors.dns({
|
||||||
// disable IPv6
|
// disable IPv6
|
||||||
dualStack: false,
|
dualStack: false,
|
||||||
@@ -126,7 +128,7 @@ const agent = new Agent({ allowH2: false });
|
|||||||
}),
|
}),
|
||||||
cacheByDefault: 600 // 10 minutes
|
cacheByDefault: 600 // 10 minutes
|
||||||
})
|
})
|
||||||
));
|
);
|
||||||
|
|
||||||
function calculateRetryAfterHeader(retryAfter: string) {
|
function calculateRetryAfterHeader(retryAfter: string) {
|
||||||
const current = Date.now();
|
const current = Date.now();
|
||||||
|
|||||||
Reference in New Issue
Block a user