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