summaryrefslogtreecommitdiff
path: root/ext/fetch
diff options
context:
space:
mode:
authorDivy Srivastava <dj.srivastava23@gmail.com>2024-11-07 17:12:13 +0530
committerGitHub <noreply@github.com>2024-11-07 17:12:13 +0530
commitb9262130fec34137e38c922015c6b671c0fa9396 (patch)
treef8095a4939560aadbf9bd11d2dcc55f75d4e38a4 /ext/fetch
parent742744d4985548a948bc90e78673c0c22d607d8a (diff)
feat(ext/http): abort signal when request is cancelled (#26761)
Closes https://github.com/denoland/deno/issues/21653
Diffstat (limited to 'ext/fetch')
-rw-r--r--ext/fetch/23_request.js16
1 files changed, 11 insertions, 5 deletions
diff --git a/ext/fetch/23_request.js b/ext/fetch/23_request.js
index 6211e927d..22c17d6d2 100644
--- a/ext/fetch/23_request.js
+++ b/ext/fetch/23_request.js
@@ -269,19 +269,25 @@ 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) {
+ // This signal has not been created yet, but the request has already completed
+ if (signal === false) {
const signal = newSignal();
this[_signalCache] = signal;
+ signal[signalAbort](signalAbortError);
return signal;
}
- // This signal has not been created yet, but the request has already completed
- if (signal === false) {
+
+ // This signal not been created yet, and the request is still in progress
+ if (signal === undefined) {
const signal = newSignal();
this[_signalCache] = signal;
- signal[signalAbort](signalAbortError);
return signal;
}
+
+ if (!signal.aborted && this[_request].isCancelled) {
+ signal[signalAbort](signalAbortError);
+ }
+
return signal;
}
get [_mimeType]() {