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

timeout options doesn't work as expected #58

Open
akeonly opened this issue Dec 20, 2021 · 4 comments
Open

timeout options doesn't work as expected #58

akeonly opened this issue Dec 20, 2021 · 4 comments

Comments

@akeonly
Copy link

akeonly commented Dec 20, 2021

I tried this line without internet access and after approximately 9 seconds later it return error "Error: Couldn't find your IP"
publicIp.v4({timeout:100}).then(value => console.log(value)).catch(err => console.log(err));

I was expecting it to error out within 100 milliseconds, not 9000 milliseconds.
Am I missing something?

@sindresorhus
Copy link
Owner

Are you using the browser or Node.js version? Can you try the latest version? It has a lot of improvements in the networking code.

@Richienb
Copy link
Contributor

The timeout applies to every request, instead of the function as a whole.

request: options.timeout,

@nikitaeverywhere
Copy link

nikitaeverywhere commented Dec 14, 2023

+1, more to add: I'm on a home router that's configured to use ipv4 only, and locally the timeout actually never works

  • Expectation: 2 seconds and it fails
  • Reality: ~30 seconds of loading and it fails

image

@barroudjo
Copy link

Same problem here, using a timeout of 1000 results in an actual error only after 12 seconds. And looking at the code I understand why: several attempts are made sequentially (with different DNS servers, with different HTTPS servers), and each attempt uses the timeout value. So obviously the overall timeout will be much longer...

So I'd say either use Promise.any for all the DNS attempts and all the HTTPS attempts, or make it clearer in the documentation that the timeout applies to each individual attempt, and is not a timeout for the publicIp() request.

I can make a pull request for either of these solutions, if you're OK with one of the two !

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Projects
None yet
Development

No branches or pull requests

5 participants