feat(ext/http): abort signal when request is cancelled (#26761)

Closes https://github.com/denoland/deno/issues/21653
This commit is contained in:
Divy Srivastava 2024-11-07 17:12:13 +05:30 committed by GitHub
parent 742744d498
commit b9262130fe
No known key found for this signature in database
GPG key ID: B5690EEEBB952194
5 changed files with 58 additions and 6 deletions

View file

@ -269,12 +269,6 @@ class Request {
/** @type {AbortSignal} */
get [_signal]() {
const signal = this[_signalCache];
// This signal not been created yet, and the request is still in progress
if (signal === undefined) {
const signal = newSignal();
this[_signalCache] = signal;
return signal;
}
// This signal has not been created yet, but the request has already completed
if (signal === false) {
const signal = newSignal();
@ -282,6 +276,18 @@ class Request {
signal[signalAbort](signalAbortError);
return signal;
}
// This signal not been created yet, and the request is still in progress
if (signal === undefined) {
const signal = newSignal();
this[_signalCache] = signal;
return signal;
}
if (!signal.aborted && this[_request].isCancelled) {
signal[signalAbort](signalAbortError);
}
return signal;
}
get [_mimeType]() {