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,3 +1,16 @@
/**
* Relay abort without forwarding the Event argument as the abort reason.
* Using .bind() avoids closure scope capture (memory leak prevention).
*/
function relayAbort(this: AbortController) {
this.abort();
}
/** Returns a bound abort relay for use as an event listener. */
export function bindAbortRelay(controller: AbortController): () => void {
return relayAbort.bind(controller);
}
/**
* Fetch wrapper that adds timeout support via AbortController.
*