GV

GeezerVison

The World Wide Web, restored to 800 pixels of glory.

Home|About|Gaming cabinet|Archives|How it works|Starter sites

On this site

  • Sign in
  • ActionsCI/CD and automation
  • CodespacesCloud development environments
  • All Features
  • Documentation
  • Training
  • Certifications
  • Build with Copilot
  • Customize Copilot
  • Integrations
  • Trending repos
  • GitHub Sponsors
  • Developer articles
  • Enterprises

This view

  • Original page
  • New address

GeezerVison is showing github.com — dns: fix getServers return undefined · nodejs/node@67b4edd

File tree

Expand file treeCollapse file tree
Open diff view settings
Filter options
  • lib/internal/dns
    • utils.js
  • test/parallel
    • test-dns-get-server.js
Expand file treeCollapse file tree
Open diff view settings
Collapse file

‎lib/internal/dns/utils.js‎

Copy file name to clipboardExpand all lines: lib/internal/dns/utils.js
+2-2Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -61,7 +61,7 @@ class Resolver {
6161
}
6262

6363
getServers() {
64-
return ArrayPrototypeMap(this._handle.getServers(), (val) => {
64+
return ArrayPrototypeMap(this._handle.getServers() || [], (val) => {
6565
if (!val[1] || val[1] === IANA_DNS_PORT)
6666
return val[0];
6767

@@ -76,7 +76,7 @@ class Resolver {
7676
// Cache the original servers because in the event of an error while
7777
// setting the servers, c-ares won't have any servers available for
7878
// resolution.
79-
const orig = this._handle.getServers();
79+
const orig = this._handle.getServers() || [];
8080
const newSet = [];
8181

8282
ArrayPrototypeForEach(servers, (serv, index) => {
Collapse file

‎test/parallel/test-dns-get-server.js‎

Copy file name to clipboard
+11Lines changed: 11 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,11 @@
1+
'use strict';
2+
const common = require('../common');
3+
const assert = require('assert');
4+
5+
const { Resolver } = require('dns');
6+
7+
const resolver = new Resolver();
8+
assert(resolver.getServers().length > 0);
9+
// return undefined
10+
resolver._handle.getServers = common.mustCall(() => {});
11+
assert.strictEqual(resolver.getServers().length, 0);

0 commit comments

Comments
0 (0)
You are visitor 01402503 — GeezerVison does not store the pages you look up.
Best viewed with Netscape Navigator 4.7 or Internet Explorer 6 at 800×600. No cookies required.