fix: use relayAbort helper for addEventListener to preserve AbortError reason

This commit is contained in:
Marcus Castro
2026-02-06 20:51:04 -03:00
committed by Peter Steinberger
parent 5ac8d1d2bb
commit 7ec60d6449
5 changed files with 58 additions and 17 deletions

View File

@@ -1,4 +1,5 @@
import type { AnyAgentTool } from "./pi-tools.types.js";
import { bindAbortRelay } from "../utils/fetch-timeout.js";
function throwAbortError(): never {
const err = new Error("Aborted");
@@ -36,7 +37,7 @@ function combineAbortSignals(a?: AbortSignal, b?: AbortSignal): AbortSignal | un
}
const controller = new AbortController();
const onAbort = controller.abort.bind(controller);
const onAbort = bindAbortRelay(controller);
a?.addEventListener("abort", onAbort, { once: true });
b?.addEventListener("abort", onAbort, { once: true });
return controller.signal;