got 14.4.2 → 14.4.4

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
@@ -132,7 +132,13 @@ export default class Request extends Duplex {
132
132
  }
133
133
  if (this.options.signal) {
134
134
  const abort = () => {
135
- this.destroy(new AbortError(this));
135
+ // See https://developer.mozilla.org/en-US/docs/Web/API/AbortSignal/timeout_static#return_value
136
+ if (this.options.signal?.reason?.name === 'TimeoutError') {
137
+ this.destroy(new TimeoutError(this.options.signal.reason, this.timings, this));
138
+ }
139
+ else {
140
+ this.destroy(new AbortError(this));
141
+ }
136
142
  };
137
143
  if (this.options.signal.aborted) {
138
144
  abort();
@@ -732,13 +738,13 @@ export default class Request extends Duplex {
732
738
  }
733
739
  })();
734
740
  }
735
- else if (event === 'abort') {
741
+ else if (event === 'abort' || event === 'destroy') {
736
742
  // The empty catch is needed here in case when
737
743
  // it rejects before it's `await`ed in `_makeRequest`.
738
744
  (async () => {
739
745
  try {
740
746
  const request = (await result);
741
- request.once('abort', handler);
747
+ request.once(event, handler);
742
748
  }
743
749
  catch { }
744
750
  })();
@@ -1131,7 +1131,7 @@ export default class Options {
1131
1131
  h2session: http2wrapper.ClientHttp2Session | undefined;
1132
1132
  decompress: boolean;
1133
1133
  prefixUrl: string | URL;
1134
- body: string | Readable | Buffer | Generator<unknown, any, unknown> | AsyncGenerator<unknown, any, unknown> | FormDataLike | undefined;
1134
+ body: string | Readable | Buffer | Generator<unknown, any, any> | AsyncGenerator<unknown, any, any> | FormDataLike | undefined;
1135
1135
  form: Record<string, any> | undefined;
1136
1136
  url: string | URL | undefined;
1137
1137
  cookieJar: PromiseCookieJar | ToughCookieJar | undefined;
@@ -21,7 +21,7 @@ export type PlainResponse = {
21
21
  /**
22
22
  The remote IP address.
23
23
 
24
- This is hopefully a temporary limitation, see [lukechilds/cacheable-request#86](https://github.com/lukechilds/cacheable-request/issues/86).
24
+ This is hopefully a temporary limitation, see [lukechilds/cacheable-request#86](https://web.archive.org/web/20220804165050/https://github.com/jaredwray/cacheable-request/issues/86).
25
25
 
26
26
  __Note__: Not available when the response is cached.
27
27
  */
@@ -1,11 +1,8 @@
1
+ import { setTimeout as delay } from 'node:timers/promises';
1
2
  import is, { assert } from '@sindresorhus/is';
2
3
  import asPromise from './as-promise/index.js';
3
4
  import Request from './core/index.js';
4
5
  import Options from './core/options.js';
5
- // The `delay` package weighs 10KB (!)
6
- const delay = async (ms) => new Promise(resolve => {
7
- setTimeout(resolve, ms);
8
- });
9
6
  const isGotInstance = (value) => is.function(value);
10
7
  const aliases = [
11
8
  'get',
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "got",
3
- "version": "14.4.2",
3
+ "version": "14.4.4",
4
4
  "description": "Human-friendly and powerful HTTP request library for Node.js",
5
5
  "license": "MIT",
6
6
  "repository": "sindresorhus/got",
@@ -48,7 +48,7 @@
48
48
  "ky"
49
49
  ],
50
50
  "dependencies": {
51
- "@sindresorhus/is": "^7.0.0",
51
+ "@sindresorhus/is": "^7.0.1",
52
52
  "@szmarczak/http-timer": "^5.0.1",
53
53
  "cacheable-lookup": "^7.0.0",
54
54
  "cacheable-request": "^12.0.1",
@@ -58,50 +58,50 @@
58
58
  "lowercase-keys": "^3.0.0",
59
59
  "p-cancelable": "^4.0.1",
60
60
  "responselike": "^3.0.0",
61
- "type-fest": "^4.19.0"
61
+ "type-fest": "^4.26.1"
62
62
  },
63
63
  "devDependencies": {
64
64
  "@hapi/bourne": "^3.0.0",
65
- "@sindresorhus/tsconfig": "^5.0.0",
65
+ "@sindresorhus/tsconfig": "^6.0.0",
66
66
  "@sinonjs/fake-timers": "^11.2.2",
67
67
  "@types/benchmark": "^2.1.5",
68
- "@types/express": "^4.17.21",
69
- "@types/node": "^20.12.12",
68
+ "@types/express": "^5.0.0",
69
+ "@types/node": "^22.7.5",
70
70
  "@types/pem": "^1.14.4",
71
71
  "@types/readable-stream": "^4.0.14",
72
72
  "@types/request": "^2.48.12",
73
73
  "@types/sinon": "^17.0.2",
74
74
  "@types/sinonjs__fake-timers": "^8.1.5",
75
75
  "ava": "^5.3.1",
76
- "axios": "^1.6.8",
76
+ "axios": "^1.7.7",
77
77
  "benchmark": "^2.1.4",
78
78
  "bluebird": "^3.7.2",
79
- "body-parser": "^1.20.2",
79
+ "body-parser": "^1.20.3",
80
80
  "create-cert": "^1.0.6",
81
81
  "create-test-server": "^3.0.1",
82
- "del-cli": "^5.1.0",
82
+ "del-cli": "^6.0.0",
83
83
  "delay": "^6.0.0",
84
- "expect-type": "^0.19.0",
85
- "express": "^4.19.2",
84
+ "expect-type": "^1.0.0",
85
+ "express": "^4.21.1",
86
86
  "form-data": "^4.0.0",
87
87
  "formdata-node": "^6.0.3",
88
88
  "get-stream": "^9.0.1",
89
- "nock": "^13.5.4",
89
+ "nock": "^13.5.5",
90
90
  "node-fetch": "^3.3.2",
91
91
  "np": "^10.0.5",
92
- "nyc": "^15.1.0",
92
+ "nyc": "^17.1.0",
93
93
  "p-event": "^6.0.1",
94
94
  "pem": "^1.14.8",
95
95
  "pify": "^6.1.0",
96
96
  "readable-stream": "^4.4.2",
97
97
  "request": "^2.88.2",
98
- "sinon": "^18.0.0",
98
+ "sinon": "^19.0.2",
99
99
  "slow-stream": "0.0.4",
100
100
  "tempy": "^3.1.0",
101
101
  "then-busboy": "^5.2.1",
102
102
  "tough-cookie": "^4.1.4",
103
- "tsx": "^4.10.4",
104
- "typescript": "^5.4.5",
103
+ "tsx": "^4.19.1",
104
+ "typescript": "^5.6.3",
105
105
  "xo": "^0.56.0"
106
106
  },
107
107
  "ava": {
package/readme.md CHANGED
@@ -5,6 +5,8 @@
5
5
  <br>
6
6
  <br>
7
7
  <br>
8
+ <br>
9
+ <hr>
8
10
  <p>
9
11
  <p>
10
12
  <sup>
@@ -13,41 +15,6 @@
13
15
  </p>
14
16
  <br>
15
17
  <br>
16
- <a href="https://retool.com/?utm_campaign=sindresorhus">
17
- <img src="https://sindresorhus.com/assets/thanks/retool-logo.svg" width="220">
18
- </a>
19
- <br>
20
- <br>
21
- <br>
22
- <a href="https://strapi.io/?ref=sindresorhus">
23
- <div>
24
- <img src="https://sindresorhus.com/assets/thanks/strapi-logo-white-bg.png" width="200" alt="Strapi">
25
- </div>
26
- <b>Strapi is the leading open-source headless CMS.</b>
27
- <div>
28
- <sup>It’s 100% JavaScript, fully customizable, and developer-first.</sup>
29
- </div>
30
- </a>
31
- <br>
32
- <br>
33
- <br>
34
- <a href="https://serpapi.com#gh-light-mode-only">
35
- <div>
36
- <img src="https://sindresorhus.com/assets/thanks/serpapi-logo-light.svg" width="130" alt="SerpApi">
37
- </div>
38
- <b>API to get search engine results with ease.</b>
39
- </a>
40
- <a href="https://serpapi.com#gh-dark-mode-only">
41
- <div>
42
- <img src="https://sindresorhus.com/assets/thanks/serpapi-logo-dark.svg" width="120" alt="SerpApi">
43
- </div>
44
- <b>API to get search engine results with ease.</b>
45
- </a>
46
- <br>
47
- <br>
48
- <br>
49
- <br>
50
- <br>
51
18
  <a href="https://www.fame.fi#gh-light-mode-only">
52
19
  <img src="https://sindresorhus.com/assets/thanks/fame-logo-light.svg" width="200" alt="Fame Helsinki">
53
20
  </a>
@@ -58,8 +25,28 @@
58
25
  <br>
59
26
  <br>
60
27
  <br>
61
- <br>
28
+ <a href="https://encore.dev?utm_campaign=github_repo&utm_medium=referral&utm_content=sindre&utm_source=github">
29
+ <div>
30
+ <picture>
31
+ <source width="230" media="(prefers-color-scheme: dark)" srcset="https://sindresorhus.com/assets/thanks/encore-logo-dark.svg">
32
+ <source width="230" media="(prefers-color-scheme: light)" srcset="https://sindresorhus.com/assets/thanks/encore-logo-light.svg">
33
+ <img width="230" src="https://sindresorhus.com/assets/thanks/encore-logo-light.svg" alt="Encore logo">
34
+ </picture>
35
+ </div>
36
+ <b>The development platform for building type-safe distributed systems</b>
37
+ <div>
38
+ <sup>End-to-end tooling from local development to automated DevOps and infrastructure in your AWS/GCP.</sup>
39
+ </div>
40
+ <br>
41
+ <br>
42
+ </a>
62
43
  </p>
44
+ <hr>
45
+ <br>
46
+ <br>
47
+ <br>
48
+ <br>
49
+ <br>
63
50
  <br>
64
51
  <br>
65
52
  </div>
@@ -185,14 +172,14 @@ By default, Got will retry on failure. To disable this option, set [`options.ret
185
172
 
186
173
  | | `got` | [`node-fetch`][n0] | [`ky`][k0] | [`axios`][a0] | [`superagent`][s0] |
187
174
  |-----------------------|:-------------------:|:--------------------:|:------------------------:|:------------------:|:----------------------:|
188
- | HTTP/2 support | :heavy_check_mark:¹ | :x: | :x: | :x: | :heavy_check_mark:\*\* |
175
+ | HTTP/2 support | :heavy_check_mark:¹ | :x: | :heavy_check_mark: | :x: | :heavy_check_mark:\*\* |
189
176
  | Browser support | :x: | :heavy_check_mark:\* | :heavy_check_mark: | :heavy_check_mark: | :heavy_check_mark: |
190
177
  | Promise API | :heavy_check_mark: | :heavy_check_mark: | :heavy_check_mark: | :heavy_check_mark: | :heavy_check_mark: |
191
178
  | Stream API | :heavy_check_mark: | Node.js only | :x: | :x: | :heavy_check_mark: |
192
179
  | Pagination API | :heavy_check_mark: | :x: | :x: | :x: | :x: |
193
180
  | Request cancelation | :heavy_check_mark: | :heavy_check_mark: | :heavy_check_mark: | :heavy_check_mark: | :heavy_check_mark: |
194
181
  | RFC compliant caching | :heavy_check_mark: | :x: | :x: | :x: | :x: |
195
- | Cookies (out-of-the-box) | :heavy_check_mark: | :x: | :x: | :x: | :x: |
182
+ | Cookies (out-of-the-box) | :heavy_check_mark: | :x: | :x: | :x: | :x: |
196
183
  | Follows redirects | :heavy_check_mark: | :heavy_check_mark: | :heavy_check_mark: | :heavy_check_mark: | :heavy_check_mark: |
197
184
  | Retries on failure | :heavy_check_mark: | :x: | :heavy_check_mark: | :x: | :heavy_check_mark: |
198
185
  | Progress events | :heavy_check_mark: | :x: | :heavy_check_mark:\*\*\* | Browser only | :heavy_check_mark: |