-
Notifications
You must be signed in to change notification settings - Fork 29.8k
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
How to add max timeout on DNS query? #7231
Comments
Good question. I don't think there's any timeout control exposed in As for a possible implementation, instead of adding another static method (like the ill-conceived |
The other dns functions use c-ares. It has a configurable timeout but unfortunately that is effectively a per-process setting. It can be configured on a per-channel basis but node uses only one channel for efficiency reasons. |
http://stackoverflow.com/questions/10777657/node-js-dns-lookup-how-to-set-timeout The stop async thread realy stop the parent process? |
* feat: support lookup with timeout nodejs/node#7231 * refactor: add meaningful error name * feat: allow to set default query timeout
Any chance of this getting added? It seems like such a simple feature to wait this long. |
It seems like this is a feature request that is unlikely to be implemented, at least not without changes in upstream c-ares. I'm going to close this, but please comment (or re-open) if you think that it should stay open. |
It's certainly something that should be in any DNS lib. I'm getting requests to implement a timeout as some lookups are taking 30s+ |
As a workaround, start a timer in parallel. If the timer expires before you get an answer back, tell the caller it timed out and ignore the answer once it does come in. |
Agreed that it seems this is the only other option, but I'm under the impression it will still hold up any future lookups as it's not actually stopping. eg. #8436 |
Yes, that's true for |
As I can understand Have you any plans for support cancellation for |
@ikokostya I think I can try to work for this feature |
Giving a request its own channel with |
@bnoordhuis @XadillaX I’ve been thinking it might make sense to expose ways to manage c-ares channels manually from JS, basically just to reduce the global state that’s inherent in having a single one per environment (then making |
Not opposed but depends on what the API would look like. Too much direct exposure of implementation details would make it hard to move away from c-ares if we ever needed to do that. |
@addaleax I wonder how the performance it will be if we use a single channel (it means we |
@XadillaX Bad, most likely. It does a lot of things: parsing config files, parsing environment variables, and so on. It would be a very nice solution if it weren't for the overhead. Maybe someone can look into adding a less expensive version of |
PR for my suggestion: #14518 |
This can be used to implement custom timeouts. Fixes: nodejs#7231
Ref: #7231 PR-URL: #14518 Reviewed-By: James M Snell <[email protected]> Reviewed-By: Colin Ihrig <[email protected]> Reviewed-By: Tobias Nießen <[email protected]>
Ref: #7231 PR-URL: #14518 Reviewed-By: James M Snell <[email protected]> Reviewed-By: Colin Ihrig <[email protected]> Reviewed-By: Tobias Nießen <[email protected]>
This can be used to implement custom timeouts. Fixes: #7231 PR-URL: #14518 Reviewed-By: James M Snell <[email protected]> Reviewed-By: Colin Ihrig <[email protected]> Reviewed-By: Tobias Nießen <[email protected]>
For example, the request a MX query is a very very long response, how to set by example 8 seconds to stop connection and launch the error callback?
The text was updated successfully, but these errors were encountered: