core: fix aggregate error handle

This commit is contained in:
undefined committed 2026-08-30 15:40:49 +00:00
1 parent 11fc1f59c9
commit 9e08afbccd
2 files changed
+10 -5

No files matched your search

+9 -4
View File
@@ -56,6 +56,10 @@ async function forkContextWithScope(ctx: CordisContext) {
};
}
function unwrapAggregateError(error: any) {
return error instanceof AggregateError ? error.errors[0] : error;
}
export interface HydroRequest {
method: string;
host: string;
@@ -601,11 +605,12 @@ ${c.response.status} ${endTime - startTime}ms ${c.response.length}`);
} else current++;
}
} catch (e) {
const error = unwrapAggregateError(e);
try {
// FIXME: should pass type check
await (this.ctx.serial as any)(`handler/error/${name}`, h, e);
await (this.ctx.serial as any)('handler/error', h, e);
await h.onerror(e);
await (this.ctx.serial as any)(`handler/error/${name}`, h, error);
await (this.ctx.serial as any)('handler/error', h, error);
await h.onerror(error);
} catch (err) {
logger.error(err);
h.response.status = 500;
@@ -726,7 +731,7 @@ ${c.response.status} ${endTime - startTime}ms ${c.response.length}`);
}
} catch (e) {
// error during initialization (prepare, hooks)
await clean(e);
await clean(unwrapAggregateError(e));
}
}