nodejs / node

Node.js JavaScript runtime ✨🐢🚀✨
https://nodejs.org
Other
107.64k stars 29.61k forks source link

net.autoSelectFamilyAttemptTimeoutDefault should not be constant #52082

Open callmebar opened 7 months ago

callmebar commented 7 months ago

What is the problem this feature will solve?

I have slow Internet connection and when a domain with multiple ip appears, I always get ETIMEDOUT because the connection can not be established in default autoSelectFamilyAttemptTimeoutDefault=250ms. There are a lot of npm packages that use node:net, and it'not possible to wait until all of them implement a mechanism to deal with autoSelectFamilyAttemptTimeout.

What is the feature you are proposing to solve the problem?

I believe it should be fixed by setting autoSelectFamilyAttemptTimeoutDefault in NODE_OPTIONS

What alternatives have you considered?

Now, it's possible to change this parameter by calling net.setDefaultAutoSelectFamilyAttemptTimeout, but I can call it only in my own code, but not from other applications (e.g. yarn), so it won't help in most cases. Alternatively, you can just increase the default parameter, but it is not flexible solution.

marco-ippolito commented 7 months ago

cc @ShogunPanda

ShogunPanda commented 7 months ago

I'm totally in for this. Would you like to send a PR? Otherwise I'll try to implement shortly.

jazelly commented 2 months ago

This has probably been fixed by https://github.com/nodejs/node/pull/52474