From 16c4a29afc9b5b410c461bab3b270f3b69e4bb27 Mon Sep 17 00:00:00 2001 From: Sergiy Kyrylkov Date: Sat, 11 Feb 2023 09:51:55 +0100 Subject: [PATCH 1/8] feat: change bodyTimeout and headersTimeout to 300s --- docs/api/Client.md | 4 ++-- types/client.d.ts | 4 ++-- 2 files changed, 4 insertions(+), 4 deletions(-) diff --git a/docs/api/Client.md b/docs/api/Client.md index 1aca7d09d31..9469f7c22bd 100644 --- a/docs/api/Client.md +++ b/docs/api/Client.md @@ -17,8 +17,8 @@ Returns: `Client` ### Parameter: `ClientOptions` -* **bodyTimeout** `number | null` (optional) - Default: `30e3` - The timeout after which a request will time out, in milliseconds. Monitors time between receiving body data. Use `0` to disable it entirely. Defaults to 30 seconds. -* **headersTimeout** `number | null` (optional) - Default: `30e3` - The amount of time the parser will wait to receive the complete HTTP headers while not sending the request. Defaults to 30 seconds. +* **bodyTimeout** `number | null` (optional) - Default: `300e3` - The timeout after which a request will time out, in milliseconds. Monitors time between receiving body data. Use `0` to disable it entirely. Defaults to 300 seconds. +* **headersTimeout** `number | null` (optional) - Default: `300e3` - The amount of time the parser will wait to receive the complete HTTP headers while not sending the request. Defaults to 300 seconds. * **keepAliveMaxTimeout** `number | null` (optional) - Default: `600e3` - The maximum allowed `keepAliveTimeout` when overridden by *keep-alive* hints from the server. Defaults to 10 minutes. * **keepAliveTimeout** `number | null` (optional) - Default: `4e3` - The timeout after which a socket without active requests will time out. Monitors time between activity on a connected socket. This value may be overridden by *keep-alive* hints from the server. See [MDN: HTTP - Headers - Keep-Alive directives](https://developer.mozilla.org/en-US/docs/Web/HTTP/Headers/Keep-Alive#directives) for more details. Defaults to 4 seconds. * **keepAliveTimeoutThreshold** `number | null` (optional) - Default: `1e3` - A number subtracted from server *keep-alive* hints when overriding `keepAliveTimeout` to account for timing inaccuracies caused by e.g. transport latency. Defaults to 1 second. diff --git a/types/client.d.ts b/types/client.d.ts index 3a954ac83a1..bb9010bfb18 100644 --- a/types/client.d.ts +++ b/types/client.d.ts @@ -31,9 +31,9 @@ declare namespace Client { connect?: buildConnector.BuildOptions | buildConnector.connector | null; /** The maximum length of request headers in bytes. Default: `16384` (16KiB). */ maxHeaderSize?: number | null; - /** The timeout after which a request will time out, in milliseconds. Monitors time between receiving body data. Use `0` to disable it entirely. Default: `30e3` milliseconds (30s). */ + /** The timeout after which a request will time out, in milliseconds. Monitors time between receiving body data. Use `0` to disable it entirely. Default: `300e3` milliseconds (300s). */ bodyTimeout?: number | null; - /** The amount of time the parser will wait to receive the complete HTTP headers (Node 14 and above only). Default: `30e3` milliseconds (30s). */ + /** The amount of time the parser will wait to receive the complete HTTP headers (Node 14 and above only). Default: `300e3` milliseconds (300s). */ headersTimeout?: number | null; /** If `true`, an error is thrown when the request content-length header doesn't match the length of the request body. Default: `true`. */ strictContentLength?: boolean; From 5b359ad375a4f837a10613e9e620f1f11becf8f8 Mon Sep 17 00:00:00 2001 From: Sergiy Kyrylkov Date: Sat, 11 Feb 2023 11:16:17 +0100 Subject: [PATCH 2/8] feat: revert bodyTimeout to 30s --- docs/api/Client.md | 2 +- types/client.d.ts | 2 +- 2 files changed, 2 insertions(+), 2 deletions(-) diff --git a/docs/api/Client.md b/docs/api/Client.md index 9469f7c22bd..a02a4ddd650 100644 --- a/docs/api/Client.md +++ b/docs/api/Client.md @@ -17,7 +17,7 @@ Returns: `Client` ### Parameter: `ClientOptions` -* **bodyTimeout** `number | null` (optional) - Default: `300e3` - The timeout after which a request will time out, in milliseconds. Monitors time between receiving body data. Use `0` to disable it entirely. Defaults to 300 seconds. +* **bodyTimeout** `number | null` (optional) - Default: `30e3` - The timeout after which a request will time out, in milliseconds. Monitors time between receiving body data. Use `0` to disable it entirely. Defaults to 30 seconds. * **headersTimeout** `number | null` (optional) - Default: `300e3` - The amount of time the parser will wait to receive the complete HTTP headers while not sending the request. Defaults to 300 seconds. * **keepAliveMaxTimeout** `number | null` (optional) - Default: `600e3` - The maximum allowed `keepAliveTimeout` when overridden by *keep-alive* hints from the server. Defaults to 10 minutes. * **keepAliveTimeout** `number | null` (optional) - Default: `4e3` - The timeout after which a socket without active requests will time out. Monitors time between activity on a connected socket. This value may be overridden by *keep-alive* hints from the server. See [MDN: HTTP - Headers - Keep-Alive directives](https://developer.mozilla.org/en-US/docs/Web/HTTP/Headers/Keep-Alive#directives) for more details. Defaults to 4 seconds. diff --git a/types/client.d.ts b/types/client.d.ts index bb9010bfb18..d70f1c50774 100644 --- a/types/client.d.ts +++ b/types/client.d.ts @@ -31,7 +31,7 @@ declare namespace Client { connect?: buildConnector.BuildOptions | buildConnector.connector | null; /** The maximum length of request headers in bytes. Default: `16384` (16KiB). */ maxHeaderSize?: number | null; - /** The timeout after which a request will time out, in milliseconds. Monitors time between receiving body data. Use `0` to disable it entirely. Default: `300e3` milliseconds (300s). */ + /** The timeout after which a request will time out, in milliseconds. Monitors time between receiving body data. Use `0` to disable it entirely. Default: `30e3` milliseconds (30s). */ bodyTimeout?: number | null; /** The amount of time the parser will wait to receive the complete HTTP headers (Node 14 and above only). Default: `300e3` milliseconds (300s). */ headersTimeout?: number | null; From 1a356a3f8552223d9949ee4fdeb155dba9d56418 Mon Sep 17 00:00:00 2001 From: Sergiy Kyrylkov Date: Sat, 11 Feb 2023 11:29:35 +0100 Subject: [PATCH 3/8] fix: update headersTimeout default to 300e3 --- lib/client.js | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/lib/client.js b/lib/client.js index 983e7034795..cb3444e05a5 100644 --- a/lib/client.js +++ b/lib/client.js @@ -213,7 +213,7 @@ class Client extends DispatcherBase { this[kNeedDrain] = 0 // 0, idle, 1, scheduled, 2 resuming this[kHostHeader] = `host: ${this[kUrl].hostname}${this[kUrl].port ? `:${this[kUrl].port}` : ''}\r\n` this[kBodyTimeout] = bodyTimeout != null ? bodyTimeout : 30e3 - this[kHeadersTimeout] = headersTimeout != null ? headersTimeout : 30e3 + this[kHeadersTimeout] = headersTimeout != null ? headersTimeout : 300e3 this[kStrictContentLength] = strictContentLength == null ? true : strictContentLength this[kMaxRedirections] = maxRedirections this[kMaxRequests] = maxRequestsPerClient From 78a0552d1b1d65bae4a215aab5ecdfd7f3ee550d Mon Sep 17 00:00:00 2001 From: Sergiy Kyrylkov Date: Sat, 11 Feb 2023 18:13:51 +0100 Subject: [PATCH 4/8] fix: update timeout test --- test/socket-timeout.js | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/test/socket-timeout.js b/test/socket-timeout.js index 8019c74198a..4cea001a56c 100644 --- a/test/socket-timeout.js +++ b/test/socket-timeout.js @@ -74,8 +74,8 @@ test('Disable socket timeout', (t) => { server.once('request', (req, res) => { setTimeout(() => { res.end('hello') - }, 31e3) - clock.tick(32e3) + }, 301e3) + clock.tick(302e3) }) t.teardown(server.close.bind(server)) From 176742fce6ba22105c3f94328ff595cac5cc066d Mon Sep 17 00:00:00 2001 From: Sergiy Kyrylkov Date: Sat, 11 Feb 2023 18:27:41 +0100 Subject: [PATCH 5/8] Revert "fix: update timeout test" This reverts commit 78a0552d1b1d65bae4a215aab5ecdfd7f3ee550d. --- test/socket-timeout.js | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/test/socket-timeout.js b/test/socket-timeout.js index 4cea001a56c..8019c74198a 100644 --- a/test/socket-timeout.js +++ b/test/socket-timeout.js @@ -74,8 +74,8 @@ test('Disable socket timeout', (t) => { server.once('request', (req, res) => { setTimeout(() => { res.end('hello') - }, 301e3) - clock.tick(302e3) + }, 31e3) + clock.tick(32e3) }) t.teardown(server.close.bind(server)) From 4a8b044ef681a4ec2f9a01612366f4312068b8dc Mon Sep 17 00:00:00 2001 From: Sergiy Kyrylkov Date: Tue, 14 Feb 2023 21:43:21 +0100 Subject: [PATCH 6/8] fix: address request-timeout.js failures --- test/request-timeout.js | 8 ++++---- 1 file changed, 4 insertions(+), 4 deletions(-) diff --git a/test/request-timeout.js b/test/request-timeout.js index 972ebd0b373..6382a6d4581 100644 --- a/test/request-timeout.js +++ b/test/request-timeout.js @@ -609,8 +609,8 @@ test('stream timeout', (t) => { const server = createServer((req, res) => { setTimeout(() => { res.end('hello') - }, 31e3) - clock.tick(31e3) + }, 301e3) + clock.tick(301e3) }) t.teardown(server.close.bind(server)) @@ -683,8 +683,8 @@ test('pipeline timeout', (t) => { const server = createServer((req, res) => { setTimeout(() => { req.pipe(res) - }, 31e3) - clock.tick(31e3) + }, 301e3) + clock.tick(301e3) }) t.teardown(server.close.bind(server)) From ee9c9cdd4e77a979329648498fdc94e486691a1b Mon Sep 17 00:00:00 2001 From: Sergiy Kyrylkov Date: Wed, 15 Feb 2023 12:07:06 +0100 Subject: [PATCH 7/8] fix: update Dispatcher headersTimeout docs to 300s --- docs/api/Dispatcher.md | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/docs/api/Dispatcher.md b/docs/api/Dispatcher.md index 25c980d612b..2b9f7bac8b3 100644 --- a/docs/api/Dispatcher.md +++ b/docs/api/Dispatcher.md @@ -200,7 +200,7 @@ Returns: `Boolean` - `false` if dispatcher is busy and further dispatch calls wo * **blocking** `boolean` (optional) - Default: `false` - Whether the response is expected to take a long time and would end up blocking the pipeline. When this is set to `true` further pipelining will be avoided on the same connection until headers have been received. * **upgrade** `string | null` (optional) - Default: `null` - Upgrade the request. Should be used to specify the kind of upgrade i.e. `'Websocket'`. * **bodyTimeout** `number | null` (optional) - The timeout after which a request will time out, in milliseconds. Monitors time between receiving body data. Use `0` to disable it entirely. Defaults to 30 seconds. -* **headersTimeout** `number | null` (optional) - The amount of time the parser will wait to receive the complete HTTP headers while not sending the request. Defaults to 30 seconds. +* **headersTimeout** `number | null` (optional) - The amount of time the parser will wait to receive the complete HTTP headers while not sending the request. Defaults to 300 seconds. * **throwOnError** `boolean` (optional) - Default: `false` - Whether Undici should throw an error upon receiving a 4xx or 5xx response from the server. #### Parameter: `DispatchHandler` From 56d79598aeb171466c870ca6af90438e77c8984b Mon Sep 17 00:00:00 2001 From: Sergiy Kyrylkov Date: Fri, 17 Feb 2023 11:16:23 +0100 Subject: [PATCH 8/8] feat: change bodyTimeout to 300s --- docs/api/Client.md | 2 +- docs/api/Dispatcher.md | 2 +- lib/client.js | 2 +- types/client.d.ts | 2 +- types/dispatcher.d.ts | 4 ++-- 5 files changed, 6 insertions(+), 6 deletions(-) diff --git a/docs/api/Client.md b/docs/api/Client.md index a02a4ddd650..9469f7c22bd 100644 --- a/docs/api/Client.md +++ b/docs/api/Client.md @@ -17,7 +17,7 @@ Returns: `Client` ### Parameter: `ClientOptions` -* **bodyTimeout** `number | null` (optional) - Default: `30e3` - The timeout after which a request will time out, in milliseconds. Monitors time between receiving body data. Use `0` to disable it entirely. Defaults to 30 seconds. +* **bodyTimeout** `number | null` (optional) - Default: `300e3` - The timeout after which a request will time out, in milliseconds. Monitors time between receiving body data. Use `0` to disable it entirely. Defaults to 300 seconds. * **headersTimeout** `number | null` (optional) - Default: `300e3` - The amount of time the parser will wait to receive the complete HTTP headers while not sending the request. Defaults to 300 seconds. * **keepAliveMaxTimeout** `number | null` (optional) - Default: `600e3` - The maximum allowed `keepAliveTimeout` when overridden by *keep-alive* hints from the server. Defaults to 10 minutes. * **keepAliveTimeout** `number | null` (optional) - Default: `4e3` - The timeout after which a socket without active requests will time out. Monitors time between activity on a connected socket. This value may be overridden by *keep-alive* hints from the server. See [MDN: HTTP - Headers - Keep-Alive directives](https://developer.mozilla.org/en-US/docs/Web/HTTP/Headers/Keep-Alive#directives) for more details. Defaults to 4 seconds. diff --git a/docs/api/Dispatcher.md b/docs/api/Dispatcher.md index 2b9f7bac8b3..c7ce70caec2 100644 --- a/docs/api/Dispatcher.md +++ b/docs/api/Dispatcher.md @@ -199,7 +199,7 @@ Returns: `Boolean` - `false` if dispatcher is busy and further dispatch calls wo * **idempotent** `boolean` (optional) - Default: `true` if `method` is `'HEAD'` or `'GET'` - Whether the requests can be safely retried or not. If `false` the request won't be sent until all preceding requests in the pipeline has completed. * **blocking** `boolean` (optional) - Default: `false` - Whether the response is expected to take a long time and would end up blocking the pipeline. When this is set to `true` further pipelining will be avoided on the same connection until headers have been received. * **upgrade** `string | null` (optional) - Default: `null` - Upgrade the request. Should be used to specify the kind of upgrade i.e. `'Websocket'`. -* **bodyTimeout** `number | null` (optional) - The timeout after which a request will time out, in milliseconds. Monitors time between receiving body data. Use `0` to disable it entirely. Defaults to 30 seconds. +* **bodyTimeout** `number | null` (optional) - The timeout after which a request will time out, in milliseconds. Monitors time between receiving body data. Use `0` to disable it entirely. Defaults to 300 seconds. * **headersTimeout** `number | null` (optional) - The amount of time the parser will wait to receive the complete HTTP headers while not sending the request. Defaults to 300 seconds. * **throwOnError** `boolean` (optional) - Default: `false` - Whether Undici should throw an error upon receiving a 4xx or 5xx response from the server. diff --git a/lib/client.js b/lib/client.js index cb3444e05a5..40ee44c6665 100644 --- a/lib/client.js +++ b/lib/client.js @@ -212,7 +212,7 @@ class Client extends DispatcherBase { this[kResuming] = 0 // 0, idle, 1, scheduled, 2 resuming this[kNeedDrain] = 0 // 0, idle, 1, scheduled, 2 resuming this[kHostHeader] = `host: ${this[kUrl].hostname}${this[kUrl].port ? `:${this[kUrl].port}` : ''}\r\n` - this[kBodyTimeout] = bodyTimeout != null ? bodyTimeout : 30e3 + this[kBodyTimeout] = bodyTimeout != null ? bodyTimeout : 300e3 this[kHeadersTimeout] = headersTimeout != null ? headersTimeout : 300e3 this[kStrictContentLength] = strictContentLength == null ? true : strictContentLength this[kMaxRedirections] = maxRedirections diff --git a/types/client.d.ts b/types/client.d.ts index d70f1c50774..bb9010bfb18 100644 --- a/types/client.d.ts +++ b/types/client.d.ts @@ -31,7 +31,7 @@ declare namespace Client { connect?: buildConnector.BuildOptions | buildConnector.connector | null; /** The maximum length of request headers in bytes. Default: `16384` (16KiB). */ maxHeaderSize?: number | null; - /** The timeout after which a request will time out, in milliseconds. Monitors time between receiving body data. Use `0` to disable it entirely. Default: `30e3` milliseconds (30s). */ + /** The timeout after which a request will time out, in milliseconds. Monitors time between receiving body data. Use `0` to disable it entirely. Default: `300e3` milliseconds (300s). */ bodyTimeout?: number | null; /** The amount of time the parser will wait to receive the complete HTTP headers (Node 14 and above only). Default: `300e3` milliseconds (300s). */ headersTimeout?: number | null; diff --git a/types/dispatcher.d.ts b/types/dispatcher.d.ts index 68135d1e5c1..c6b0c8875eb 100644 --- a/types/dispatcher.d.ts +++ b/types/dispatcher.d.ts @@ -109,9 +109,9 @@ declare namespace Dispatcher { blocking?: boolean; /** Upgrade the request. Should be used to specify the kind of upgrade i.e. `'Websocket'`. Default: `method === 'CONNECT' || null`. */ upgrade?: boolean | string | null; - /** The amount of time the parser will wait to receive the complete HTTP headers. Defaults to 30 seconds. */ + /** The amount of time the parser will wait to receive the complete HTTP headers. Defaults to 300 seconds. */ headersTimeout?: number | null; - /** The timeout after which a request will time out, in milliseconds. Monitors time between receiving body data. Use 0 to disable it entirely. Defaults to 30 seconds. */ + /** The timeout after which a request will time out, in milliseconds. Monitors time between receiving body data. Use 0 to disable it entirely. Defaults to 300 seconds. */ bodyTimeout?: number | null; /** Whether the request should stablish a keep-alive or not. Default `false` */ reset?: boolean;