From 0506a4a229c08af939ddaeb154f51ba2847d755c Mon Sep 17 00:00:00 2001 From: gregonarash <48462103+gregonarash@users.noreply.github.com> Date: Tue, 15 Oct 2024 15:09:19 +0000 Subject: [PATCH 1/2] doc(ETIMEDOUT): adding details of updating network family autoselection timeout to avoid ETIMEDOUT error --- docs/docs/best-practices/etimedout-errors.md | 32 ++++++++++++++++++++ 1 file changed, 32 insertions(+) create mode 100644 docs/docs/best-practices/etimedout-errors.md diff --git a/docs/docs/best-practices/etimedout-errors.md b/docs/docs/best-practices/etimedout-errors.md new file mode 100644 index 00000000000..dda8556cfcc --- /dev/null +++ b/docs/docs/best-practices/etimedout-errors.md @@ -0,0 +1,32 @@ +# ETIMEDOUT - network family autoselection timeout errors + +If you are experiencing `TypeError: fetch failed` and you are able to investigate the `cause: AggregateError` and see `code: 'ETIMEDOUT'` it can be very likely due to timeout network family autoaselection. This tends to happen with DNS resolving domain to multiple ipv4 and ipv6 addresses. + +The default timeout depends on local Node version, on Node 18.13.0 and above is 250 milliseconds. + +### Increasing timeout by updating Node options directly + +`export NODE_OPTIONS="--network-family-autoselection-attempt-timeout=500"` + +### Increasing timeout by updating Node options in package.json + +On example of a NextJS project: + +``` +{ + "private": true, + "scripts": { + "dev": "NODE_OPTIONS='--network-family-autoselection-attempt-timeout=500' next dev", + "build": "next build", + "start": "next start", + "debug": "NODE_OPTIONS='--inspect-brk' next dev" + }, + "dependencies": { + ... + } +} +``` + +### Increasing timeout by updating Undici Client with ClientOptions + +You can also specify `autoSelectFamilyAttemptTimeout` option with a new Undici client. [Read more in the docs](https://github.com/nodejs/undici/blob/main/docs/docs/api/Client.md#parameter-connectoptions) From 54fc8a03fd2e4b4e5672c7d4834a48cc11acae6e Mon Sep 17 00:00:00 2001 From: Carlos Fuentes Date: Wed, 15 Jan 2025 11:25:44 +0100 Subject: [PATCH 2/2] fix: Update docs/docs/best-practices/etimedout-errors.md MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit Co-authored-by: Mickaƫl Derriey --- docs/docs/best-practices/etimedout-errors.md | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/docs/docs/best-practices/etimedout-errors.md b/docs/docs/best-practices/etimedout-errors.md index dda8556cfcc..16e3af25aba 100644 --- a/docs/docs/best-practices/etimedout-errors.md +++ b/docs/docs/best-practices/etimedout-errors.md @@ -1,6 +1,6 @@ # ETIMEDOUT - network family autoselection timeout errors -If you are experiencing `TypeError: fetch failed` and you are able to investigate the `cause: AggregateError` and see `code: 'ETIMEDOUT'` it can be very likely due to timeout network family autoaselection. This tends to happen with DNS resolving domain to multiple ipv4 and ipv6 addresses. +If you are experiencing `TypeError: fetch failed` and you are able to investigate the `cause: AggregateError` and see `code: 'ETIMEDOUT'` it can be very likely due to timeout network family autoselection. This tends to happen with DNS resolving domain to multiple ipv4 and ipv6 addresses. The default timeout depends on local Node version, on Node 18.13.0 and above is 250 milliseconds.