Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

doc(ETIMEDOUT): updating network family autoselection timeout to avoid ETIMEDOUT error #3738

Open
wants to merge 2 commits into
base: main
Choose a base branch
from
Open
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
32 changes: 32 additions & 0 deletions docs/docs/best-practices/etimedout-errors.md
Original file line number Diff line number Diff line change
@@ -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.
Copy link

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Suggested change
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.

### 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
metcoder95 marked this conversation as resolved.
Show resolved Hide resolved

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)
Loading