Skip to content

Commit

Permalink
dns: report out of memory properly
Browse files Browse the repository at this point in the history
This addresses a part of a TODO by properly reporting an out of
memory error to the user instead of reporting `ENOTFOUND`.

PR-URL: #20317
Reviewed-By: Ben Noordhuis <info@bnoordhuis.nl>
Reviewed-By: Colin Ihrig <cjihrig@gmail.com>
Reviewed-By: Trivikram Kamat <trivikr.dev@gmail.com>
  • Loading branch information
BridgeAR committed Apr 30, 2018
1 parent 283a967 commit a158d41
Show file tree
Hide file tree
Showing 3 changed files with 3 additions and 6 deletions.
5 changes: 1 addition & 4 deletions lib/internal/errors.js
Original file line number Diff line number Diff line change
Expand Up @@ -29,7 +29,6 @@ const READABLE_OPERATOR = {

const {
errmap,
UV_EAI_MEMORY,
UV_EAI_NODATA,
UV_EAI_NONAME
} = process.binding('uv');
Expand Down Expand Up @@ -640,9 +639,7 @@ function dnsException(code, syscall, hostname) {
if (typeof code === 'number') {
// FIXME(bnoordhuis) Remove this backwards compatibility nonsense and pass
// the true error to the user. ENOTFOUND is not even a proper POSIX error!
if (code === UV_EAI_MEMORY ||
code === UV_EAI_NODATA ||
code === UV_EAI_NONAME) {
if (code === UV_EAI_NODATA || code === UV_EAI_NONAME) {
code = 'ENOTFOUND'; // Fabricated error name.
} else {
code = lazyInternalUtil().getSystemErrorName(code);
Expand Down
2 changes: 1 addition & 1 deletion test/parallel/test-http-dns-error.js
Original file line number Diff line number Diff line change
Expand Up @@ -29,7 +29,7 @@ const assert = require('assert');
const http = require('http');
const https = require('https');

const host = '*'.repeat(256);
const host = '*'.repeat(64);
const MAX_TRIES = 5;

let errCode = 'ENOTFOUND';
Expand Down
2 changes: 1 addition & 1 deletion test/parallel/test-net-dns-error.js
Original file line number Diff line number Diff line change
Expand Up @@ -25,7 +25,7 @@ const common = require('../common');
const assert = require('assert');
const net = require('net');

const host = '*'.repeat(256);
const host = '*'.repeat(64);
const errCode = common.isOpenBSD ? 'EAI_FAIL' : 'ENOTFOUND';

const socket = net.connect(42, host, common.mustNotCall());
Expand Down

0 comments on commit a158d41

Please sign in to comment.