got 14.4.5 → 14.4.6

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.
@@ -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.6",
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