You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
{{ message }}
Repository navigation
dns.setServers doesn't play well with async code #1071
The current target server is stored in a per-app global state, which would probably be fine with sync code, but complicates things if you want to query multiple servers with our async resolve.
I'd propose adding an options object to resolve containing servers, while deprecating dns.setServers in a major version. I think having an option object on resolve methods could prove useful later.
Note: I haven't checked if c-ares enables per-query target servers easily, maybe @indutny can comment on that part.
Hm... this is not a bad suggestion at all, but I this is not the way c-ares works :) The thing that you propose will require creating and keeping alive separate channels in a hashmap.
changed the title [-]Deprecate `dns.setServers` - Replace it with an option on `resolve`[/-][+]`dns.setServers` doesn't play well with async code[/+]on Mar 5, 2015
It looks like #1843 might be stalling out (@mscdex). Thinking about this a bit, I'm wondering if a possible stop-gap "solution" would be to modify setServers() such that it will throw early if there are any pending resolves that have not yet returned. Ultimately I think the right solution is to allow multiple resolvers as @piscisaureus has suggested but that's a larger change. If we did go that route, setServers() would be deprecated anyway. Adding the throw would seem to be better than allowing the current existing failure.
@jasnell I'm all for it if it avoids the crash. It would give the user a chance to workaround.
Regarding alternatives, @mafintosh's dns-socket is a pretty flexible JS DNS solution I've been using recently. Maybe worth investigating how its perf compares to @mscdex's implementation.
Yes, I believe #13050 actually does fix this. Good catch. There are still a number of ways that the dns module can be improved, but the change in #13050 addresses the immediate issue. Closing. In any of the collaborators feel that it's necessary to do so, we can reopen the issue.
Activity
indutny commentedon Mar 5, 2015
Hm... this is not a bad suggestion at all, but I this is not the way c-ares works :) The thing that you propose will require creating and keeping alive separate channels in a hashmap.
silverwind commentedon Mar 5, 2015
Ah, so there is a reason it's implemented in this way.
Maybe something that should be kept in mind for #1013.
piscisaureus commentedon Mar 5, 2015
Another solution would be to allow multiple "resolver" instances, e.g. support the following pattern:
The default
lookupmethod would just delegate to a default resolver.indutny commentedon Mar 5, 2015
Please don't close this, I didn't mean that it wasn't feasible :) Just wanted to stress out how it will be implemented.
silverwind commentedon Mar 5, 2015
This is what node-dns basically does. It's an option, but I think I'm leaning more towards the option object for simplicity.
[-]Deprecate `dns.setServers` - Replace it with an option on `resolve`[/-][+]`dns.setServers` doesn't play well with async code[/+]ChALkeR commentedon Mar 5, 2015
Atm, dns.setServers asserts when there are running dns queries or callbacks of dns queries.
This crashes:
This works:
silverwind commentedon Mar 6, 2015
@ChALkeR this is known, see #894.
snsparrish commentedon Jun 7, 2015
I hope this idea hasn't died. I'd really like to see this functionality. The node-dns alternative doesn't appear to be functioning at all in 2.2.1.
silverwind commentedon Jun 7, 2015
I have a change for this i mind after the new DNS implementation lands (#1843 (comment))
Trott commentedon Mar 11, 2016
I'm going to add a
stalledlabel until #1843 comes together. Feel free to remove if that's an abuse of that particular label.jasnell commentedon Apr 19, 2016
It looks like #1843 might be stalling out (@mscdex). Thinking about this a bit, I'm wondering if a possible stop-gap "solution" would be to modify
setServers()such that it will throw early if there are any pending resolves that have not yet returned. Ultimately I think the right solution is to allow multiple resolvers as @piscisaureus has suggested but that's a larger change. If we did go that route,setServers()would be deprecated anyway. Adding the throw would seem to be better than allowing the current existing failure.silverwind commentedon Apr 19, 2016
@jasnell I'm all for it if it avoids the crash. It would give the user a chance to workaround.
Regarding alternatives, @mafintosh's dns-socket is a pretty flexible JS DNS solution I've been using recently. Maybe worth investigating how its perf compares to @mscdex's implementation.
XadillaX commentedon May 17, 2017
Hey @silverwind, does #13050 fix this?
jasnell commentedon May 30, 2017
Yes, I believe #13050 actually does fix this. Good catch. There are still a number of ways that the
dnsmodule can be improved, but the change in #13050 addresses the immediate issue. Closing. In any of the collaborators feel that it's necessary to do so, we can reopen the issue.