wrap AbortSignal

This commit is contained in:
Kenta Moriuchi 2025-08-21 21:00:18 +09:00
parent 3c174f9ed1
commit 8338652401
No known key found for this signature in database
GPG key ID: AC843C584A91BE0C
11 changed files with 692 additions and 360 deletions

View file

@ -272,7 +272,8 @@ class Request {
if (signal === false) {
const signal = newSignal();
this[_signalCache] = signal;
signal[signalAbort](
signalAbort(
signal,
new DOMException(MESSAGE_REQUEST_CANCELLED, "AbortError"),
);
return signal;
@ -283,7 +284,8 @@ class Request {
const signal = newSignal();
this[_signalCache] = signal;
this[_request].onCancel?.(() => {
signal[signalAbort](
signalAbort(
signal,
new DOMException(MESSAGE_REQUEST_CANCELLED, "AbortError"),
);
});
@ -609,7 +611,8 @@ const MESSAGE_REQUEST_CANCELLED = "The request has been cancelled.";
function abortRequest(request) {
if (request[_signalCache] !== undefined) {
request[_signal][signalAbort](
signalAbort(
request[_signal],
new DOMException(MESSAGE_REQUEST_CANCELLED, "AbortError"),
);
} else {