got 14.4.5 → 14.4.7

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.
@@ -328,7 +328,7 @@ export default class Request extends Duplex {
328
328
  if (!error) {
329
329
  this._bodySize = this._uploadedSize;
330
330
  this.emit('uploadProgress', this.uploadProgress);
331
- this._request.emit('upload-complete');
331
+ this._request?.emit('upload-complete');
332
332
  }
333
333
  callback(error);
334
334
  });
@@ -1128,29 +1128,22 @@ export default class Options {
1128
1128
  followRedirect: boolean | ((response: PlainResponse) => boolean);
1129
1129
  retry: Partial<RetryOptions>;
1130
1130
  agent: Agents;
1131
- h2session: http2wrapper.ClientHttp2Session | undefined;
1131
+ h2session: ClientHttp2Session | undefined;
1132
1132
  decompress: boolean;
1133
1133
  prefixUrl: string | URL;
1134
- body: string | Readable | Buffer | Generator<unknown, any, any> | AsyncGenerator<unknown, any, any> | FormDataLike | undefined;
1134
+ body: string | Buffer | Readable | Generator | AsyncGenerator | FormDataLike | undefined;
1135
1135
  form: Record<string, any> | undefined;
1136
1136
  url: string | URL | undefined;
1137
1137
  cookieJar: PromiseCookieJar | ToughCookieJar | undefined;
1138
1138
  signal: AbortSignal | undefined;
1139
1139
  ignoreInvalidCookies: boolean;
1140
- searchParams: string | URLSearchParams | SearchParameters | undefined;
1141
- dnsLookup: {
1142
- (hostname: string, family: import("cacheable-lookup").IPFamily, callback: (error: NodeJS.ErrnoException | null, address: string, family: import("cacheable-lookup").IPFamily) => void): void;
1143
- (hostname: string, callback: (error: NodeJS.ErrnoException | null, address: string, family: import("cacheable-lookup").IPFamily) => void): void;
1144
- (hostname: string, options: import("cacheable-lookup").LookupOptions & {
1145
- all: true;
1146
- }, callback: (error: NodeJS.ErrnoException | null, result: ReadonlyArray<import("cacheable-lookup").EntryObject>) => void): void;
1147
- (hostname: string, options: import("cacheable-lookup").LookupOptions, callback: (error: NodeJS.ErrnoException | null, address: string, family: import("cacheable-lookup").IPFamily) => void): void;
1148
- } | undefined;
1149
- dnsCache: boolean | CacheableLookup | undefined;
1140
+ searchParams: string | SearchParameters | URLSearchParams | undefined;
1141
+ dnsLookup: CacheableLookup["lookup"] | undefined;
1142
+ dnsCache: CacheableLookup | boolean | undefined;
1150
1143
  context: Record<string, unknown>;
1151
1144
  hooks: Hooks;
1152
1145
  maxRedirects: number;
1153
- cache: string | boolean | StorageAdapter | undefined;
1146
+ cache: string | StorageAdapter | boolean | undefined;
1154
1147
  throwHttpErrors: boolean;
1155
1148
  http2: boolean;
1156
1149
  allowGetBody: boolean;
@@ -1174,9 +1167,9 @@ export default class Options {
1174
1167
  };
1175
1168
  createNativeRequestOptions(): {
1176
1169
  ALPNProtocols: string[] | undefined;
1177
- ca: string | Buffer | (string | Buffer)[] | undefined;
1178
- cert: string | Buffer | (string | Buffer)[] | undefined;
1179
- key: string | Buffer | (string | Buffer | import("tls").KeyObject)[] | undefined;
1170
+ ca: string | Buffer<ArrayBufferLike> | (string | Buffer<ArrayBufferLike>)[] | undefined;
1171
+ cert: string | Buffer<ArrayBufferLike> | (string | Buffer<ArrayBufferLike>)[] | undefined;
1172
+ key: string | Buffer<ArrayBufferLike> | (string | Buffer<ArrayBufferLike> | import("tls").KeyObject)[] | undefined;
1180
1173
  passphrase: string | undefined;
1181
1174
  pfx: PfxType;
1182
1175
  rejectUnauthorized: boolean | undefined;
@@ -1187,9 +1180,9 @@ export default class Options {
1187
1180
  maxVersion: import("tls").SecureVersion | undefined;
1188
1181
  sigalgs: string | undefined;
1189
1182
  sessionTimeout: number | undefined;
1190
- dhparam: string | Buffer | undefined;
1183
+ dhparam: string | Buffer<ArrayBufferLike> | undefined;
1191
1184
  ecdhCurve: string | undefined;
1192
- crl: string | Buffer | (string | Buffer)[] | undefined;
1185
+ crl: string | Buffer<ArrayBufferLike> | (string | Buffer<ArrayBufferLike>)[] | undefined;
1193
1186
  lookup: {
1194
1187
  (hostname: string, family: import("cacheable-lookup").IPFamily, callback: (error: NodeJS.ErrnoException | null, address: string, family: import("cacheable-lookup").IPFamily) => void): void;
1195
1188
  (hostname: string, callback: (error: NodeJS.ErrnoException | null, address: string, family: import("cacheable-lookup").IPFamily) => void): void;
@@ -1219,6 +1212,7 @@ export default class Options {
1219
1212
  path?: string | null | undefined;
1220
1213
  port?: number | string | null | undefined;
1221
1214
  protocol?: string | null | undefined;
1215
+ setDefaultHeaders?: boolean | undefined;
1222
1216
  signal?: AbortSignal | undefined;
1223
1217
  socketPath?: string | undefined;
1224
1218
  uniqueHeaders?: Array<string | string[]> | undefined;
@@ -1227,6 +1221,7 @@ export default class Options {
1227
1221
  servername: string;
1228
1222
  protocols: string[];
1229
1223
  }) => string | undefined) | undefined;
1224
+ allowPartialTrustChain?: boolean | undefined;
1230
1225
  clientCertEngine?: string | undefined;
1231
1226
  privateKeyEngine?: string | undefined;
1232
1227
  privateKeyIdentifier?: string | undefined;
@@ -19,10 +19,12 @@ export default function timedOut(request, delays, options) {
19
19
  request[reentry] = true;
20
20
  const cancelers = [];
21
21
  const { once, unhandleAll } = unhandler();
22
+ const handled = new Map();
22
23
  const addTimeout = (delay, callback, event) => {
23
24
  const timeout = setTimeout(callback, delay, delay, event);
24
25
  timeout.unref?.();
25
26
  const cancel = () => {
27
+ handled.set(event, true);
26
28
  clearTimeout(timeout);
27
29
  };
28
30
  cancelers.push(cancel);
@@ -30,7 +32,13 @@ export default function timedOut(request, delays, options) {
30
32
  };
31
33
  const { host, hostname } = options;
32
34
  const timeoutHandler = (delay, event) => {
33
- request.destroy(new TimeoutError(delay, event));
35
+ // Use setTimeout to allow for any cancelled events to be handled first,
36
+ // to prevent firing any TimeoutError unneeded when the event loop is busy or blocked
37
+ setTimeout(() => {
38
+ if (!handled.has(event)) {
39
+ request.destroy(new TimeoutError(delay, event));
40
+ }
41
+ }, 0);
34
42
  };
35
43
  const cancelTimeouts = () => {
36
44
  for (const cancel of cancelers) {
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "got",
3
- "version": "14.4.5",
3
+ "version": "14.4.7",
4
4
  "description": "Human-friendly and powerful HTTP request library for Node.js",
5
5
  "license": "MIT",
6
6
  "repository": "sindresorhus/got",
package/readme.md CHANGED
@@ -22,24 +22,6 @@
22
22
  <img src="https://sindresorhus.com/assets/thanks/fame-logo-dark.svg" width="200" alt="Fame Helsinki">
23
23
  </a>
24
24
  <br>
25
- <br>
26
- <br>
27
- <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>
43
25
  </p>
44
26
  <hr>
45
27
  <br>
@@ -61,7 +43,7 @@
61
43
 
62
44
  ---
63
45
 
64
- **You probably want [Ky](https://github.com/sindresorhus/ky) instead, by the same people. It's smaller, works in the browser too, and is more stable since it's built upon [`Fetch`](https://developer.mozilla.org/en-US/docs/Web/API/Fetch_API).**
46
+ **You probably want [Ky](https://github.com/sindresorhus/ky) instead, by the same people. It's smaller, works in the browser too, and is more stable since it's built on [`Fetch`](https://developer.mozilla.org/en-US/docs/Web/API/Fetch_API). Or [fetch-extras](https://github.com/sindresorhus/fetch-extras) for simple needs.**
65
47
 
66
48
  ---
67
49