Skip to content

Commit 24eec6f

Browse files
authored
Test support of AbortSignal.any() (#711)
1 parent 3207ecc commit 24eec6f

File tree

2 files changed

+3
-1
lines changed

2 files changed

+3
-1
lines changed

source/core/Ky.ts

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -20,6 +20,7 @@ import {
2020
responseTypes,
2121
stop,
2222
supportsAbortController,
23+
supportsAbortSignal,
2324
supportsFormData,
2425
supportsResponseStreams,
2526
supportsRequestStreams,
@@ -168,7 +169,7 @@ export class Ky {
168169
this._input = this._options.prefixUrl + this._input;
169170
}
170171

171-
if (supportsAbortController) {
172+
if (supportsAbortController && supportsAbortSignal) {
172173
const originalSignal = this._options.signal ?? (this._input as Request).signal;
173174
this.abortController = new globalThis.AbortController();
174175
this._options.signal = originalSignal ? AbortSignal.any([originalSignal, this.abortController.signal]) : this.abortController.signal;

source/core/constants.ts

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -33,6 +33,7 @@ export const supportsRequestStreams = (() => {
3333
})();
3434

3535
export const supportsAbortController = typeof globalThis.AbortController === 'function';
36+
export const supportsAbortSignal = typeof globalThis.AbortSignal === 'function' && typeof globalThis.AbortSignal.any === 'function';
3637
export const supportsResponseStreams = typeof globalThis.ReadableStream === 'function';
3738
export const supportsFormData = typeof globalThis.FormData === 'function';
3839

0 commit comments

Comments
 (0)