From f4d04f9f69f7467af59ef729e6add9f24fc80760 Mon Sep 17 00:00:00 2001 From: PopGoesTheWza Date: Tue, 10 Aug 2021 00:18:25 +0200 Subject: [PATCH 1/5] doc: clarify retryWithMergedOptions valid hooks --- documentation/9-hooks.md | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/documentation/9-hooks.md b/documentation/9-hooks.md index 9bda9bba9..1c4a487cf 100644 --- a/documentation/9-hooks.md +++ b/documentation/9-hooks.md @@ -222,7 +222,7 @@ await got('https://httpbin.org/status/500', { > - When using the Stream API, this hook is ignored. **Note:** -> - Calling the retry function will trigger `beforeRetry` hooks. +> - Calling the `retryWithMergedOptions` function will trigger `beforeRetry` and possibly `beforeError` hooks. Meanwhile the `init`, `beforeRequest` , `beforeRedirect` and `afterResponse` hooks will be skipped. Each function should return the response. This is especially useful when you want to refresh an access token. From e24e5164b872e7d3e338182f616fc77d646a5096 Mon Sep 17 00:00:00 2001 From: PopGoesTheWza Date: Tue, 10 Aug 2021 01:41:50 +0200 Subject: [PATCH 2/5] doc: clarify retryWithMergedOptions valid hooks --- documentation/9-hooks.md | 6 +++--- source/core/options.ts | 4 +++- 2 files changed, 6 insertions(+), 4 deletions(-) diff --git a/documentation/9-hooks.md b/documentation/9-hooks.md index 1c4a487cf..2cfe0bc92 100644 --- a/documentation/9-hooks.md +++ b/documentation/9-hooks.md @@ -218,13 +218,13 @@ await got('https://httpbin.org/status/500', { (response: Response, retryWithMergedOptions: (options: OptionsInit) => never) => Promisable> ``` +Each function should return the response. This is especially useful when you want to refresh an access token. + **Note:** > - When using the Stream API, this hook is ignored. **Note:** -> - Calling the `retryWithMergedOptions` function will trigger `beforeRetry` and possibly `beforeError` hooks. Meanwhile the `init`, `beforeRequest` , `beforeRedirect` and `afterResponse` hooks will be skipped. - -Each function should return the response. This is especially useful when you want to refresh an access token. +> - Calling the `retryWithMergedOptions` function will first execute any remaining `afterResponse` hooks before triggering `beforeRetry` and possibly `beforeError` hooks. Meanwhile the `init`, `beforeRequest` , `beforeRedirect` as well as already executed `afterResponse` hooks will be skipped. ```js import got from 'got'; diff --git a/source/core/options.ts b/source/core/options.ts index dfbe8ab9d..62df41a5e 100644 --- a/source/core/options.ts +++ b/source/core/options.ts @@ -186,13 +186,15 @@ export interface Hooks { /** Called with [response object](#response) and a retry function. - Calling the retry function will trigger `beforeRetry` hooks. Each function should return the response. This is especially useful when you want to refresh an access token. __Note__: When using streams, this hook is ignored. + __Note__: Calling the `retryWithMergedOptions` function will first execute any remaining `afterResponse` hooks before triggering `beforeRetry` and possibly `beforeError` hooks. + Meanwhile the `init`, `beforeRequest` , `beforeRedirect` as well as already executed `afterResponse` hooks will be skipped. + @example ``` import got from 'got'; From 62401d1dc5121d0aee29ff82b29b5d3bf6249e87 Mon Sep 17 00:00:00 2001 From: PopGoesTheWza Date: Tue, 10 Aug 2021 14:18:24 +0200 Subject: [PATCH 3/5] doc: clarify retryWithMergedOptions valid hooks --- documentation/9-hooks.md | 3 ++- source/core/options.ts | 2 +- 2 files changed, 3 insertions(+), 2 deletions(-) diff --git a/documentation/9-hooks.md b/documentation/9-hooks.md index 2cfe0bc92..85baeec53 100644 --- a/documentation/9-hooks.md +++ b/documentation/9-hooks.md @@ -224,7 +224,8 @@ Each function should return the response. This is especially useful when you wan > - When using the Stream API, this hook is ignored. **Note:** -> - Calling the `retryWithMergedOptions` function will first execute any remaining `afterResponse` hooks before triggering `beforeRetry` and possibly `beforeError` hooks. Meanwhile the `init`, `beforeRequest` , `beforeRedirect` as well as already executed `afterResponse` hooks will be skipped. +> - Calling the `retryWithMergedOptions` function will execute any remaining `afterResponse` hooks and trigger relevant `beforeRetry` and `beforeError` hooks. +Meanwhile the `init`, `beforeRequest` , `beforeRedirect` as well as already executed `afterResponse` hooks will be skipped. ```js import got from 'got'; diff --git a/source/core/options.ts b/source/core/options.ts index 62df41a5e..341983400 100644 --- a/source/core/options.ts +++ b/source/core/options.ts @@ -192,7 +192,7 @@ export interface Hooks { __Note__: When using streams, this hook is ignored. - __Note__: Calling the `retryWithMergedOptions` function will first execute any remaining `afterResponse` hooks before triggering `beforeRetry` and possibly `beforeError` hooks. + __Note__: Calling the `retryWithMergedOptions` function will execute any remaining `afterResponse` hooks and trigger relevant `beforeRetry` and `beforeError` hooks. Meanwhile the `init`, `beforeRequest` , `beforeRedirect` as well as already executed `afterResponse` hooks will be skipped. @example From a684271659a9eac1454a7b0687697785b3fddca7 Mon Sep 17 00:00:00 2001 From: PopGoesTheWza Date: Tue, 10 Aug 2021 15:25:09 +0200 Subject: [PATCH 4/5] doc: clarify retryWithMergedOptions valid hooks --- documentation/9-hooks.md | 2 +- source/core/options.ts | 2 +- 2 files changed, 2 insertions(+), 2 deletions(-) diff --git a/documentation/9-hooks.md b/documentation/9-hooks.md index 85baeec53..ae079cab2 100644 --- a/documentation/9-hooks.md +++ b/documentation/9-hooks.md @@ -224,7 +224,7 @@ Each function should return the response. This is especially useful when you wan > - When using the Stream API, this hook is ignored. **Note:** -> - Calling the `retryWithMergedOptions` function will execute any remaining `afterResponse` hooks and trigger relevant `beforeRetry` and `beforeError` hooks. +> - Calling the `retryWithMergedOptions` function will trigger `beforeRetry` hooks. If the retry is successful, all remaining `afterResponse` hooks will be called. In case of an error.`beforeRetry` hooks will be called instead. Meanwhile the `init`, `beforeRequest` , `beforeRedirect` as well as already executed `afterResponse` hooks will be skipped. ```js diff --git a/source/core/options.ts b/source/core/options.ts index 341983400..281d19e02 100644 --- a/source/core/options.ts +++ b/source/core/options.ts @@ -192,7 +192,7 @@ export interface Hooks { __Note__: When using streams, this hook is ignored. - __Note__: Calling the `retryWithMergedOptions` function will execute any remaining `afterResponse` hooks and trigger relevant `beforeRetry` and `beforeError` hooks. + __Note__: Calling the `retryWithMergedOptions` function will trigger `beforeRetry` hooks. If the retry is successful, all remaining `afterResponse` hooks will be called. In case of an error. Meanwhile the `init`, `beforeRequest` , `beforeRedirect` as well as already executed `afterResponse` hooks will be skipped. @example From 51331a09d220060a814a256fc22d3c6340c4e267 Mon Sep 17 00:00:00 2001 From: PopGoesTheWza Date: Tue, 10 Aug 2021 15:34:04 +0200 Subject: [PATCH 5/5] doc: clarify retryWithMergedOptions valid hooks --- documentation/9-hooks.md | 2 +- source/core/options.ts | 2 +- 2 files changed, 2 insertions(+), 2 deletions(-) diff --git a/documentation/9-hooks.md b/documentation/9-hooks.md index ae079cab2..e3ead6429 100644 --- a/documentation/9-hooks.md +++ b/documentation/9-hooks.md @@ -224,7 +224,7 @@ Each function should return the response. This is especially useful when you wan > - When using the Stream API, this hook is ignored. **Note:** -> - Calling the `retryWithMergedOptions` function will trigger `beforeRetry` hooks. If the retry is successful, all remaining `afterResponse` hooks will be called. In case of an error.`beforeRetry` hooks will be called instead. +> - Calling the `retryWithMergedOptions` function will trigger `beforeRetry` hooks. If the retry is successful, all remaining `afterResponse` hooks will be called. In case of an error, `beforeRetry` hooks will be called instead. Meanwhile the `init`, `beforeRequest` , `beforeRedirect` as well as already executed `afterResponse` hooks will be skipped. ```js diff --git a/source/core/options.ts b/source/core/options.ts index 281d19e02..7c070cf78 100644 --- a/source/core/options.ts +++ b/source/core/options.ts @@ -192,7 +192,7 @@ export interface Hooks { __Note__: When using streams, this hook is ignored. - __Note__: Calling the `retryWithMergedOptions` function will trigger `beforeRetry` hooks. If the retry is successful, all remaining `afterResponse` hooks will be called. In case of an error. + __Note__: Calling the `retryWithMergedOptions` function will trigger `beforeRetry` hooks. If the retry is successful, all remaining `afterResponse` hooks will be called. In case of an error, `beforeRetry` hooks will be called instead. Meanwhile the `init`, `beforeRequest` , `beforeRedirect` as well as already executed `afterResponse` hooks will be skipped. @example