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 { export interface HydroRequest {
method: string; method: string;
host: string; host: string;
@@ -601,11 +605,12 @@ ${c.response.status} ${endTime - startTime}ms ${c.response.length}`);
} else current++; } else current++;
} }
} catch (e) { } catch (e) {
const error = unwrapAggregateError(e);
try { try {
// FIXME: should pass type check // FIXME: should pass type check
await (this.ctx.serial as any)(`handler/error/${name}`, h, e); await (this.ctx.serial as any)(`handler/error/${name}`, h, error);
await (this.ctx.serial as any)('handler/error', h, e); await (this.ctx.serial as any)('handler/error', h, error);
await h.onerror(e); await h.onerror(error);
} catch (err) { } catch (err) {
logger.error(err); logger.error(err);
h.response.status = 500; h.response.status = 500;
@@ -726,7 +731,7 @@ ${c.response.status} ${endTime - startTime}ms ${c.response.length}`);
} }
} catch (e) { } catch (e) {
// error during initialization (prepare, hooks) // error during initialization (prepare, hooks)
await clean(e); await clean(unwrapAggregateError(e));
} }
} }
+1 -1
View File
@@ -1,6 +1,6 @@
{ {
"name": "hydrooj", "name": "hydrooj",
"version": "5.0.5", "version": "5.0.6",
"bin": "bin/hydrooj.js", "bin": "bin/hydrooj.js",
"main": "src/plugin-api", "main": "src/plugin-api",
"module": "src/plugin-api", "module": "src/plugin-api",