mirror of
https://github.com/SukkaW/Surge.git
synced 2025-12-12 09:10:35 +08:00
Chore: timeout properly
This commit is contained in:
parent
48b3c4538e
commit
6ed3695e36
@ -141,8 +141,7 @@ export const buildSpeedtestDomainSet = task(import.meta.path, async () => {
|
||||
}
|
||||
}
|
||||
|
||||
let timer;
|
||||
|
||||
await new Promise<void>((resolve) => {
|
||||
const pMap = ([
|
||||
'Hong Kong',
|
||||
'Taiwan',
|
||||
@ -184,22 +183,20 @@ export const buildSpeedtestDomainSet = task(import.meta.path, async () => {
|
||||
return pMap;
|
||||
}, {});
|
||||
|
||||
try {
|
||||
timer = setTimeout(() => {
|
||||
const timer = setTimeout(() => {
|
||||
console.error(picocolors.red('Task timeout!'));
|
||||
Object.entries(pMap).forEach(([name, p]) => {
|
||||
console.log(`[${name}]`, Bun.peek.status(p));
|
||||
});
|
||||
|
||||
throw new Error('timeout');
|
||||
resolve();
|
||||
}, 1000 * 60 * 2);
|
||||
|
||||
await Promise.all(Object.values(pMap));
|
||||
} finally {
|
||||
if (timer) {
|
||||
Promise.all(Object.values(pMap)).then(() => {
|
||||
clearTimeout(timer);
|
||||
}
|
||||
}
|
||||
resolve();
|
||||
});
|
||||
});
|
||||
|
||||
const gorhill = await getGorhillPublicSuffixPromise();
|
||||
const deduped = sortDomains(domainDeduper(Array.from(domains)), gorhill);
|
||||
|
||||
@ -102,6 +102,9 @@ import type { TaskResult } from './lib/trace-runner';
|
||||
]);
|
||||
|
||||
printStats(stats);
|
||||
|
||||
// Finish the build to avoid leaking timer/fetch ref
|
||||
process.exit(0);
|
||||
} catch (e) {
|
||||
console.trace(e);
|
||||
console.error('Something went wrong!');
|
||||
|
||||
Loading…
x
Reference in New Issue
Block a user