Skip to content

Commit a004263

Browse files
authored
Require Node.js 20 (#2313)
1 parent 7c3f147 commit a004263

File tree

17 files changed

+70
-91
lines changed

17 files changed

+70
-91
lines changed

.github/workflows/main.yml

Lines changed: 4 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -12,22 +12,21 @@ jobs:
1212
fail-fast: false
1313
matrix:
1414
node-version:
15-
- 18
16-
- 16
15+
- 20
1716
os:
1817
# Ubuntu fails and I don't have time to look into it. PR welcome.
1918
# - ubuntu-latest
2019
- macos-latest
2120
# Windows fails and I don't have time to look into it. PR welcome.
2221
# - windows-latest
2322
steps:
24-
- uses: actions/checkout@v3
25-
- uses: actions/setup-node@v3
23+
- uses: actions/checkout@v4
24+
- uses: actions/setup-node@v4
2625
with:
2726
node-version: ${{ matrix.node-version }}
2827
- run: npm install
2928
- run: npm test
3029
# - uses: codecov/codecov-action@v3
31-
# if: matrix.os == 'ubuntu-latest' && matrix.node-version == 16
30+
# if: matrix.os == 'ubuntu-latest' && matrix.node-version == 20
3231
# with:
3332
# fail_ci_if_error: true

documentation/async-stack-traces.md

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -114,7 +114,7 @@ From previous event:
114114
As expected, we know where the timeout has been set. Unfortunately, if we increase our retry count limit to `1`, the stack trace remains the same. That's because `bluebird` doesn't track I/O events. Please note that this should be sufficient for most cases. In order to debug further, we can use [`async_hooks`](https://nodejs.org/api/async_hooks.html) instead. A Stack Overflow user has come up with an awesome solution:
115115
116116
```js
117-
import asyncHooks from 'async_hooks';
117+
import asyncHooks from 'node:async_hooks';
118118

119119
const traces = new Map();
120120

license

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,6 @@
11
MIT License
22

3-
Copyright (c) Sindre Sorhus <sindresorhus@gmail.com> (sindresorhus.com)
3+
Copyright (c) Sindre Sorhus <sindresorhus@gmail.com> (https://sindresorhus.com)
44

55
Permission is hereby granted, free of charge, to any person obtaining a copy of this software and associated documentation files (the "Software"), to deal in the Software without restriction, including without limitation the rights to use, copy, modify, merge, publish, distribute, sublicense, and/or sell copies of the Software, and to permit persons to whom the Software is furnished to do so, subject to the following conditions:
66

package.json

Lines changed: 42 additions & 45 deletions
Original file line numberDiff line numberDiff line change
@@ -10,11 +10,12 @@
1010
"types": "./dist/source/index.d.ts",
1111
"default": "./dist/source/index.js"
1212
},
13+
"sideEffects": false,
1314
"engines": {
14-
"node": ">=16"
15+
"node": ">=20"
1516
},
1617
"scripts": {
17-
"test": "xo && tsc --noEmit && ava",
18+
"test": "xo && tsc --noEmit && NODE_OPTIONS='--import=tsx/esm' ava",
1819
"release": "np",
1920
"build": "del-cli dist && tsc",
2021
"prepare": "npm run build"
@@ -47,64 +48,61 @@
4748
"ky"
4849
],
4950
"dependencies": {
50-
"@sindresorhus/is": "^5.2.0",
51+
"@sindresorhus/is": "^6.1.0",
5152
"@szmarczak/http-timer": "^5.0.1",
5253
"cacheable-lookup": "^7.0.0",
53-
"cacheable-request": "^10.2.8",
54+
"cacheable-request": "^10.2.14",
5455
"decompress-response": "^6.0.0",
55-
"form-data-encoder": "^2.1.2",
56-
"get-stream": "^6.0.1",
57-
"http2-wrapper": "^2.1.10",
56+
"form-data-encoder": "^4.0.2",
57+
"get-stream": "^8.0.1",
58+
"http2-wrapper": "^2.2.1",
5859
"lowercase-keys": "^3.0.0",
59-
"p-cancelable": "^3.0.0",
60+
"p-cancelable": "^4.0.1",
6061
"responselike": "^3.0.0"
6162
},
6263
"devDependencies": {
6364
"@hapi/bourne": "^3.0.0",
64-
"@sindresorhus/tsconfig": "^3.0.1",
65-
"@sinonjs/fake-timers": "^10.0.2",
66-
"@types/benchmark": "^2.1.2",
67-
"@types/express": "^4.17.17",
68-
"@types/node": "^18.14.5",
69-
"@types/pem": "^1.9.6",
70-
"@types/pify": "^5.0.1",
71-
"@types/readable-stream": "^2.3.13",
72-
"@types/request": "^2.48.8",
73-
"@types/sinon": "^10.0.11",
74-
"@types/sinonjs__fake-timers": "^8.1.1",
75-
"@types/tough-cookie": "^4.0.1",
76-
"ava": "^5.2.0",
77-
"axios": "^0.27.2",
65+
"@sindresorhus/tsconfig": "^5.0.0",
66+
"@sinonjs/fake-timers": "^11.2.2",
67+
"@types/benchmark": "^2.1.5",
68+
"@types/express": "^4.17.21",
69+
"@types/node": "^20.10.0",
70+
"@types/pem": "^1.14.4",
71+
"@types/readable-stream": "^4.0.9",
72+
"@types/request": "^2.48.12",
73+
"@types/sinon": "^17.0.2",
74+
"@types/sinonjs__fake-timers": "^8.1.5",
75+
"ava": "^5.3.1",
76+
"axios": "^1.6.2",
7877
"benchmark": "^2.1.4",
7978
"bluebird": "^3.7.2",
8079
"body-parser": "^1.20.2",
8180
"create-cert": "^1.0.6",
8281
"create-test-server": "^3.0.1",
83-
"del-cli": "^5.0.0",
84-
"delay": "^5.0.0",
85-
"express": "^4.17.3",
82+
"del-cli": "^5.1.0",
83+
"delay": "^6.0.0",
84+
"express": "^4.18.2",
8685
"form-data": "^4.0.0",
87-
"formdata-node": "^5.0.0",
88-
"nock": "^13.3.0",
89-
"node-fetch": "^3.2.3",
90-
"np": "^7.6.0",
86+
"formdata-node": "^6.0.3",
87+
"nock": "^13.4.0",
88+
"node-fetch": "^3.3.2",
89+
"np": "^9.0.0",
9190
"nyc": "^15.1.0",
92-
"p-event": "^5.0.1",
93-
"pem": "^1.14.6",
94-
"pify": "^6.0.0",
95-
"readable-stream": "^4.2.0",
91+
"p-event": "^6.0.0",
92+
"pem": "^1.14.8",
93+
"pify": "^6.1.0",
94+
"readable-stream": "^4.4.2",
9695
"request": "^2.88.2",
97-
"sinon": "^15.0.1",
96+
"sinon": "^17.0.1",
9897
"slow-stream": "0.0.4",
99-
"tempy": "^3.0.0",
98+
"tempy": "^3.1.0",
10099
"then-busboy": "^5.2.1",
101-
"tough-cookie": "4.1.2",
102-
"ts-node": "^10.8.2",
103-
"type-fest": "^3.6.1",
104-
"typescript": "^5.0.4",
105-
"xo": "^0.54.2"
100+
"tough-cookie": "^4.1.3",
101+
"tsx": "^4.6.0",
102+
"type-fest": "^4.8.2",
103+
"typescript": "^5.3.2",
104+
"xo": "^0.56.0"
106105
},
107-
"sideEffects": false,
108106
"ava": {
109107
"files": [
110108
"test/*"
@@ -113,9 +111,7 @@
113111
"extensions": {
114112
"ts": "module"
115113
},
116-
"nodeArguments": [
117-
"--loader=ts-node/esm"
118-
]
114+
"workerThreads": false
119115
},
120116
"nyc": {
121117
"reporter": [
@@ -148,7 +144,8 @@
148144
"@typescript-eslint/no-unsafe-argument": "off",
149145
"@typescript-eslint/promise-function-async": "off",
150146
"no-lone-blocks": "off",
151-
"unicorn/no-await-expression-member": "off"
147+
"unicorn/no-await-expression-member": "off",
148+
"unicorn/prefer-event-target": "off"
152149
}
153150
},
154151
"runkitExampleFilename": "./documentation/examples/runkit-example.js"

readme.md

Lines changed: 0 additions & 11 deletions
Original file line numberDiff line numberDiff line change
@@ -187,11 +187,6 @@ By default, Got will retry on failure. To disable this option, set [`options.ret
187187
- [`got-scraping`](https://github.com/apify/got-scraping) - Got wrapper specifically designed for web scraping purposes
188188
- [`got-ssrf`](https://github.com/JaneJeon/got-ssrf) - Got wrapper to protect server-side requests against SSRF attacks
189189

190-
### Legacy
191-
192-
- [travis-got](https://github.com/samverschueren/travis-got) - Got convenience wrapper to interact with the Travis API
193-
- [graphql-got](https://github.com/kevva/graphql-got) - Got convenience wrapper to interact with GraphQL
194-
195190
## Comparison
196191

197192
| | `got` | [`node-fetch`][n0] | [`ky`][k0] | [`axios`][a0] | [`superagent`][s0] |
@@ -519,9 +514,3 @@ By default, Got will retry on failure. To disable this option, set [`options.ret
519514
> Got has been a crucial component of Apify's scraping for years. We use it to extract data from billions of web pages every month, and we really appreciate the powerful API and extensibility, which allowed us to build our own specialized HTTP client on top of Got. The support has always been stellar too.
520515
>
521516
> — <a href="https://github.com/mnmkng">Ondra Urban</a>
522-
523-
## For enterprise
524-
525-
Available as part of the Tidelift Subscription.
526-
527-
The maintainers of `got` and thousands of other packages are working with Tidelift to deliver commercial support and maintenance for the open source dependencies you use to build your applications. Save time, reduce risk, and improve code health, while paying the maintainers of the exact dependencies you use. [Learn more.](https://tidelift.com/subscription/pkg/npm-got?utm_source=npm-got&utm_medium=referral&utm_campaign=enterprise&utm_term=repo)

source/as-promise/types.ts

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1,8 +1,8 @@
11
import type {Buffer} from 'node:buffer';
22
import type PCancelable from 'p-cancelable';
33
import {RequestError} from '../core/errors.js';
4-
import type Request from '../core/index.js'; // eslint-disable-line import/no-duplicates
5-
import {type RequestEvents} from '../core/index.js'; // eslint-disable-line import/no-duplicates -- It's not allowed to combine these imports. The rule is incorrect.
4+
import type Request from '../core/index.js';
5+
import {type RequestEvents} from '../core/index.js';
66
import type {Response} from '../core/response.js';
77

88
/**

source/core/index.ts

Lines changed: 1 addition & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -12,7 +12,7 @@ import CacheableRequest, {
1212
} from 'cacheable-request';
1313
import decompressResponse from 'decompress-response';
1414
import is from '@sindresorhus/is';
15-
import getStream from 'get-stream';
15+
import {getStreamAsBuffer} from 'get-stream';
1616
import {FormDataEncoder, isFormData as isFormDataLike} from 'form-data-encoder';
1717
import type ResponseLike from 'responselike';
1818
import getBodySize from './utils/get-body-size.js';
@@ -43,8 +43,6 @@ import {
4343
AbortError,
4444
} from './errors.js';
4545

46-
const {buffer: getStreamAsBuffer} = getStream;
47-
4846
type Error = NodeJS.ErrnoException;
4947

5048
export type Progress = {

source/core/parse-link-header.ts

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -9,7 +9,7 @@ export default function parseLinkHeader(link: string) {
99
const trimmedUriReference = rawUriReference.trim();
1010

1111
// eslint-disable-next-line @typescript-eslint/prefer-string-starts-ends-with
12-
if (trimmedUriReference[0] !== '<' || trimmedUriReference[trimmedUriReference.length - 1] !== '>') {
12+
if (trimmedUriReference[0] !== '<' || trimmedUriReference.at(-1) !== '>') {
1313
throw new Error(`Invalid format of the Link header reference: ${trimmedUriReference}`);
1414
}
1515

source/types.ts

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1,8 +1,8 @@
11
import type {Buffer} from 'node:buffer';
22
import type {CancelableRequest} from './as-promise/types.js';
33
import type {Response} from './core/response.js';
4-
import type Options from './core/options.js'; // eslint-disable-line import/no-duplicates
5-
import {type PaginationOptions, type OptionsInit} from './core/options.js'; // eslint-disable-line import/no-duplicates -- It's not allowed to combine these imports. The rule is incorrect.
4+
import type Options from './core/options.js';
5+
import {type PaginationOptions, type OptionsInit} from './core/options.js';
66
import type Request from './core/index.js';
77

88
// `type-fest` utilities

test/arguments.ts

Lines changed: 4 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -89,7 +89,7 @@ test('throws an error when legacy URL is passed', withServer, async (t, server)
8989
got(parse(`${server.url}/test`)),
9090
{
9191
instanceOf: RequestError,
92-
message: 'Expected value which is `predicate returns truthy for any value`, received values of types `Object`.',
92+
message: 'Expected values which are `string`, `URL`, or `undefined`. Received values of type `Object`.',
9393
},
9494
);
9595

@@ -218,7 +218,7 @@ test('throws when known `options.hooks` value is not an array', async t => {
218218
got('https://example.com', {hooks: {beforeRequest: {}}}),
219219
{
220220
instanceOf: RequestError,
221-
message: 'Expected value which is `predicate returns truthy for any value`, received values of types `Object`.',
221+
message: 'Expected values which are `Array` or `undefined`. Received values of type `Object`.',
222222
},
223223
);
224224
});
@@ -294,7 +294,7 @@ test('throws if the `searchParams` value is invalid', async t => {
294294
}),
295295
{
296296
instanceOf: RequestError,
297-
message: 'Expected value which is `predicate returns truthy for any value`, received values of types `Array`.',
297+
message: 'Expected values which are `string`, `number`, `boolean`, `null`, or `undefined`. Received values of type `Array`.',
298298
});
299299
});
300300

@@ -447,7 +447,7 @@ test('throws on invalid `dnsCache` option', async t => {
447447
}),
448448
{
449449
instanceOf: RequestError,
450-
message: 'Expected value which is `predicate returns truthy for any value`, received values of types `number`.',
450+
message: 'Expected values which are `Object`, `boolean`, or `undefined`. Received values of type `number`.',
451451
});
452452
});
453453

0 commit comments

Comments
 (0)