From c00e498a4e5c0fcd71c2f20bcb420c80d696a0bf Mon Sep 17 00:00:00 2001 From: Konrad Baumgart <konrad.baumgart@erli.pl> Date: Sun, 19 Jan 2025 22:07:11 +0100 Subject: [PATCH 1/2] docs about global dispatcher and errors (#3987) Signed-off-by: Konrad Baumgart <zuo.zp8@gmail.com> --- README.md | 3 ++- docs/docs/api/Errors.md | 3 +++ 2 files changed, 5 insertions(+), 1 deletion(-) diff --git a/README.md b/README.md index b47a5fe367c..8fa1c94d697 100644 --- a/README.md +++ b/README.md @@ -337,7 +337,8 @@ See [Dispatcher.upgrade](./docs/docs/api/Dispatcher.md#dispatcherupgradeoptions- * dispatcher `Dispatcher` -Sets the global dispatcher used by Common API Methods. +Sets the global dispatcher used by Common API Methods. Global dispatcher is shared among compatible undici modules, +including undici that is bundled internally with node.js. ### `undici.getGlobalDispatcher()` diff --git a/docs/docs/api/Errors.md b/docs/docs/api/Errors.md index c32868912a6..771e716671a 100644 --- a/docs/docs/api/Errors.md +++ b/docs/docs/api/Errors.md @@ -28,6 +28,9 @@ import { errors } from 'undici' | `ResponseExceededMaxSizeError` | `UND_ERR_RES_EXCEEDED_MAX_SIZE` | response body exceed the max size allowed | | `SecureProxyConnectionError` | `UND_ERR_PRX_TLS` | tls connection to a proxy failed | +Be aware that some errors are created by dispatcher. If you plan to check `instanceof errors.UndiciError` then don't use the default global dispatcher, +as it may come from another `undici` module and have its own errors classes. + ### `SocketError` The `SocketError` has a `.socket` property which holds socket metadata: From 5e387328e5d8f97468bfd493828a9324289ac95b Mon Sep 17 00:00:00 2001 From: Matteo Collina <matteo.collina@gmail.com> Date: Thu, 23 Jan 2025 08:51:10 -0800 Subject: [PATCH 2/2] Update docs/docs/api/Errors.md Co-authored-by: Carlos Fuentes <me@metcoder.dev> --- docs/docs/api/Errors.md | 4 +--- 1 file changed, 1 insertion(+), 3 deletions(-) diff --git a/docs/docs/api/Errors.md b/docs/docs/api/Errors.md index 771e716671a..dfba3b39ce0 100644 --- a/docs/docs/api/Errors.md +++ b/docs/docs/api/Errors.md @@ -28,9 +28,7 @@ import { errors } from 'undici' | `ResponseExceededMaxSizeError` | `UND_ERR_RES_EXCEEDED_MAX_SIZE` | response body exceed the max size allowed | | `SecureProxyConnectionError` | `UND_ERR_PRX_TLS` | tls connection to a proxy failed | -Be aware that some errors are created by dispatcher. If you plan to check `instanceof errors.UndiciError` then don't use the default global dispatcher, -as it may come from another `undici` module and have its own errors classes. - +Be aware of the possible difference between the global dispatcher version and the actual undici version you might be using. We recommend to avoid the check `instanceof errors.UndiciError` and seek for the `error.code === '<error_code>'` instead to avoid inconsistencies. ### `SocketError` The `SocketError` has a `.socket` property which holds socket metadata: