mirror of
https://github.com/zebrajr/node.git
synced 2025-12-07 12:20:50 +01: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. Fixes: https://github.com/nodejs/node/issues/14734 PR-URL: https://github.com/nodejs/node/pull/14891 Backport-PR-URL: https://github.com/nodejs/node/pull/17778 Reviewed-By: Anna Henningsen <anna@addaleax.net> Reviewed-By: Tobias Nießen <tniessen@tnie.de>
31 lines
561 B
JavaScript
31 lines
561 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), {
|
|
message: /^c-ares failed to set servers: "There are pending queries\." \[.+\]$/g
|
|
});
|
|
}
|
|
|
|
{
|
|
dns.resolve('localhost', common.mustCall());
|
|
|
|
// should not throw
|
|
dns.setServers(goog);
|
|
}
|
|
}
|