From a95e0da6b8765f80f124b1db1f808b6ae4b17287 Mon Sep 17 00:00:00 2001 From: Jonathan Stewmon Date: Wed, 25 Jul 2018 07:00:31 -0500 Subject: [PATCH 1/2] docs: DRY the timeout object section --- readme.md | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/readme.md b/readme.md index ee3058e3f..890fc317a 100644 --- a/readme.md +++ b/readme.md @@ -188,7 +188,7 @@ Type: `number` `Object` Milliseconds to wait for the server to end the response before aborting request with `ETIMEDOUT` error (a.k.a. `request` property). By default there's no timeout. -This also accepts an object with separate `lookup`, `connect`, `socket`, `response` and `request` fields to specify granular timeouts for each phase of the request. +This also accepts an `object` with the following fields to constrain the duration of each phase of the request lifecycle: - `lookup` starts when a socket is assigned and ends when the hostname has been resolved. Does not apply when using a Unix domain socket. - `connect` starts when `lookup` completes (or when the socket is assigned if lookup does not apply to the request) and ends when the socket is connected. @@ -412,7 +412,7 @@ Extends parent options. Avoid using [object spread](https://developer.mozilla.or ```js const a = {headers: {cat: 'meow'}}; const b = {headers: {dog: 'woof'}}; - + {...a, ...b} // => {headers: {dog: 'woof'}} got.assignOptions(a, b) // => {headers: {cat: 'meow', dog: 'woof'}} ``` From a2e4bbba4b93865e66000b2d47f1b70236100b1e Mon Sep 17 00:00:00 2001 From: Jonathan Stewmon Date: Wed, 25 Jul 2018 07:09:17 -0500 Subject: [PATCH 2/2] update timeout docs to mention got.TimeoutError --- readme.md | 5 ++++- 1 file changed, 4 insertions(+), 1 deletion(-) diff --git a/readme.md b/readme.md index 890fc317a..dffe717de 100644 --- a/readme.md +++ b/readme.md @@ -186,7 +186,7 @@ Query string object that will be added to the request URL. This will override th Type: `number` `Object` -Milliseconds to wait for the server to end the response before aborting request with `ETIMEDOUT` error (a.k.a. `request` property). By default there's no timeout. +Milliseconds to wait for the server to end the response before aborting request with [`got.TimeoutError`](#gottimeouterror) error (a.k.a. `request` property). By default there's no timeout. This also accepts an `object` with the following fields to constrain the duration of each phase of the request lifecycle: @@ -455,6 +455,9 @@ When given an unsupported protocol. When the request is aborted with `.cancel()`. +#### got.TimeoutError + +When the request is aborted due to a [timeout](#timeout) ## Aborting the request