Update CDN & Download Hosts

This commit is contained in:
SukkaW
2026-03-31 01:09:30 +08:00
parent 2bbfb15db0
commit d6fa78d49a
3 changed files with 26 additions and 11 deletions

View File

@@ -97,7 +97,7 @@ export function createSpan(name: string, parentTraceResult?: TraceResult): Span
return span;
}
export const dummySpan = createSpan('');
export const dummySpan = createSpan('dummy');
export function task(importMetaMain: boolean, importMetaPath: string) {
return <T>(fn: (span: Span, onCleanup: (cb: () => Promise<void> | void) => void) => Promise<T>, customName?: string) => {
@@ -107,7 +107,7 @@ export function task(importMetaMain: boolean, importMetaPath: string) {
cleanup = cb;
};
const dummySpan = createSpan(taskName);
const innerSpan = createSpan(taskName);
if (importMetaMain) {
process.on('uncaughtException', (error) => {
console.error('Uncaught exception:', error);
@@ -118,20 +118,24 @@ export function task(importMetaMain: boolean, importMetaPath: string) {
process.exit(1);
});
dummySpan.traceChildAsync('dummy', (childSpan) => fn(childSpan, onCleanup)).finally(() => {
dummySpan.stop();
printTraceResult(dummySpan.traceResult);
innerSpan.traceChildAsync('dummy', (childSpan) => fn(childSpan, onCleanup)).finally(() => {
innerSpan.stop();
printTraceResult(innerSpan.traceResult);
process.nextTick(whyIsNodeRunning);
process.nextTick(() => process.exit(0));
});
}
return async (span?: Span) => {
if (span) {
return span.traceChildAsync(taskName, (childSpan) => fn(childSpan, onCleanup).finally(() => cleanup()));
}
return fn(dummySpan, onCleanup).finally(() => cleanup());
};
function run(span?: Span | null): Promise<T> {
return fn(span || innerSpan, onCleanup).finally(() => {
(span || innerSpan).stop();
cleanup();
});
}
return Object.assign(run, {
getInternalTraceResult: () => innerSpan.traceResult
});
};
}