mirror of
https://github.com/nodejs/node.git
synced 2025-05-10 17:57:53 +00:00

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: https://github.com/nodejs/node/pull/14891 Fixes: https://github.com/nodejs/node/issues/14734 Reviewed-By: Anna Henningsen <anna@addaleax.net> Reviewed-By: Tobias Nießen <tniessen@tnie.de>
32 lines
603 B
JavaScript
32 lines
603 B
JavaScript
'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);
|
|
}
|
|
}
|