diff --git a/.github/workflows/main.yml b/.github/workflows/main.yml index bf8563bc7..73c90e339 100644 --- a/.github/workflows/main.yml +++ b/.github/workflows/main.yml @@ -12,9 +12,9 @@ jobs: fail-fast: false matrix: node-version: + - 20 - 18 - 16 - - 14 os: # Ubuntu fails and I don't have time to look into it. PR welcome. # - ubuntu-latest diff --git a/documentation/2-options.md b/documentation/2-options.md index f54a90c90..cde04e1a8 100644 --- a/documentation/2-options.md +++ b/documentation/2-options.md @@ -215,8 +215,6 @@ await got('https://httpbin.org/anything'); You can abort the `request` using [`AbortController`](https://developer.mozilla.org/en-US/docs/Web/API/AbortController). -*Requires Node.js 16 or later.* - ```js import got from 'got'; diff --git a/readme.md b/readme.md index b7b2eecf7..89c15cc72 100644 --- a/readme.md +++ b/readme.md @@ -94,7 +94,7 @@ npm install got **Warning:** This package is native [ESM](https://developer.mozilla.org/en-US/docs/Web/JavaScript/Guide/Modules) and no longer provides a CommonJS export. If your project uses CommonJS, you will have to [convert to ESM](https://gist.github.com/sindresorhus/a39789f98801d908bbc7ff3ecc99d99c) or use the [dynamic `import()`](https://v8.dev/features/dynamic-import) function. Please don't open issues for questions regarding CommonJS / ESM. -**Got v11 (the previous major version) is no longer maintained and we will not accept any backport requests.** +**Got v11 is no longer maintained and we will not accept any backport requests.** ## Take a peek diff --git a/source/core/index.ts b/source/core/index.ts index dca359e29..3e1f3e210 100644 --- a/source/core/index.ts +++ b/source/core/index.ts @@ -276,8 +276,9 @@ export default class Request extends Duplex implements RequestEvents { abort(); } else { this.options.signal.addEventListener('abort', abort); + this._removeListeners = () => { - this.options.signal.removeEventListener('abort', abort); + this.options.signal?.removeEventListener('abort', abort); }; } } diff --git a/source/core/options.ts b/source/core/options.ts index 0ec270330..d33c25d93 100644 --- a/source/core/options.ts +++ b/source/core/options.ts @@ -1499,8 +1499,6 @@ export default class Options { /** You can abort the `request` using [`AbortController`](https://developer.mozilla.org/en-US/docs/Web/API/AbortController). - *Requires Node.js 16 or later.* - @example ``` import got from 'got'; @@ -1516,13 +1514,11 @@ export default class Options { }, 100); ``` */ - // TODO: Replace `any` with `AbortSignal` when targeting Node 16. - get signal(): any | undefined { + get signal(): AbortSignal | undefined { return this._internals.signal; } - // TODO: Replace `any` with `AbortSignal` when targeting Node 16. - set signal(value: any | undefined) { + set signal(value: AbortSignal | undefined) { assert.object(value); this._internals.signal = value; diff --git a/test/cache.ts b/test/cache.ts index e023fef92..cbc6a3e0d 100644 --- a/test/cache.ts +++ b/test/cache.ts @@ -561,7 +561,8 @@ test.failing('revalidated compressed responses are retrieved from cache', withSe }); }); -test.failing('revalidated uncompressed responses from github are retrieved from cache', async t => { +// eslint-disable-next-line ava/no-skip-test -- Unreliable +test.skip('revalidated uncompressed responses from github are retrieved from cache', async t => { const client = got.extend({ cache: new Map(), cacheOptions: {shared: false}, @@ -590,7 +591,8 @@ test.failing('revalidated uncompressed responses from github are retrieved from }); }); -test.failing('revalidated compressed responses from github are retrieved from cache', async t => { +// eslint-disable-next-line ava/no-skip-test -- Unreliable +test.skip('revalidated compressed responses from github are retrieved from cache', async t => { const client = got.extend({ cache: new Map(), cacheOptions: {shared: false},