fix: use relayAbort helper for addEventListener to preserve AbortError reason
This commit is contained in:
committed by
Peter Steinberger
parent
5ac8d1d2bb
commit
7ec60d6449
@@ -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.
|
||||
*
|
||||
|
||||
Reference in New Issue
Block a user