mirror of
https://github.com/denoland/deno.git
synced 2025-02-15 10:06:23 -05:00
refactor(ext/fetch): do not share error instance (#27941)
This commit is contained in:
parent
87f6fd18c6
commit
491488628a
1 changed files with 10 additions and 9 deletions
|
@ -14,7 +14,6 @@ const {
|
|||
ArrayPrototypeMap,
|
||||
ArrayPrototypeSlice,
|
||||
ArrayPrototypeSplice,
|
||||
ObjectFreeze,
|
||||
ObjectKeys,
|
||||
ObjectPrototypeIsPrototypeOf,
|
||||
RegExpPrototypeExec,
|
||||
|
@ -273,7 +272,9 @@ class Request {
|
|||
if (signal === false) {
|
||||
const signal = newSignal();
|
||||
this[_signalCache] = signal;
|
||||
signal[signalAbort](signalAbortError);
|
||||
signal[signalAbort](
|
||||
new DOMException(MESSAGE_REQUEST_CANCELLED, "AbortError"),
|
||||
);
|
||||
return signal;
|
||||
}
|
||||
|
||||
|
@ -282,7 +283,9 @@ class Request {
|
|||
const signal = newSignal();
|
||||
this[_signalCache] = signal;
|
||||
this[_request].onCancel?.(() => {
|
||||
signal[signalAbort](signalAbortError);
|
||||
signal[signalAbort](
|
||||
new DOMException(MESSAGE_REQUEST_CANCELLED, "AbortError"),
|
||||
);
|
||||
});
|
||||
|
||||
return signal;
|
||||
|
@ -602,15 +605,13 @@ function fromInnerRequest(inner, guard) {
|
|||
return request;
|
||||
}
|
||||
|
||||
const signalAbortError = new DOMException(
|
||||
"The request has been cancelled.",
|
||||
"AbortError",
|
||||
);
|
||||
ObjectFreeze(signalAbortError);
|
||||
const MESSAGE_REQUEST_CANCELLED = "The request has been cancelled.";
|
||||
|
||||
function abortRequest(request) {
|
||||
if (request[_signalCache] !== undefined) {
|
||||
request[_signal][signalAbort](signalAbortError);
|
||||
request[_signal][signalAbort](
|
||||
new DOMException(MESSAGE_REQUEST_CANCELLED, "AbortError"),
|
||||
);
|
||||
} else {
|
||||
request[_signalCache] = false;
|
||||
}
|
||||
|
|
Loading…
Add table
Reference in a new issue