-
Notifications
You must be signed in to change notification settings - Fork 29.8k
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
dns: fix crash while setting server during query
Fix this issue follow these two points: 1. Keep track of how many queries are currently open. If `setServers()` is called while there are open queries, error out. 2. For `Resolver` instances, use option 1. For dns.setServers(), just create a fresh new default channel every time it is called, and then set its servers list. PR-URL: #14891 Fixes: #14734 Reviewed-By: Anna Henningsen <[email protected]> Reviewed-By: Tobias Nießen <[email protected]>
- Loading branch information
1 parent
619cbc4
commit 026f760
Showing
4 changed files
with
94 additions
and
21 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,31 @@ | ||
'use strict'; | ||
|
||
const common = require('../common'); | ||
|
||
const dns = require('dns'); | ||
|
||
const goog = [ | ||
'8.8.8.8', | ||
'8.8.4.4', | ||
]; | ||
|
||
{ | ||
// Fix https://github.com/nodejs/node/issues/14734 | ||
|
||
{ | ||
const resolver = new dns.Resolver(); | ||
resolver.resolve('localhost', common.mustCall()); | ||
|
||
common.expectsError(resolver.setServers.bind(resolver, goog), { | ||
code: 'ERR_DNS_SET_SERVERS_FAILED', | ||
message: /^c-ares failed to set servers: "There are pending queries\." \[.+\]$/g | ||
}); | ||
} | ||
|
||
{ | ||
dns.resolve('localhost', common.mustCall()); | ||
|
||
// should not throw | ||
dns.setServers(goog); | ||
} | ||
} |