dns: report out of memory properly

This addresses a part of a TODO by properly reporting an out of
memory error to the user instead of reporting `ENOTFOUND`.

PR-URL: https://github.com/nodejs/node/pull/20317
Reviewed-By: Ben Noordhuis <info@bnoordhuis.nl>
Reviewed-By: Colin Ihrig <cjihrig@gmail.com>
Reviewed-By: Trivikram Kamat <trivikr.dev@gmail.com>
This commit is contained in:
Ruben Bridgewater 2018-04-26 05:02:46 +02:00
parent 283a967e35
commit a158d412b3
No known key found for this signature in database
GPG Key ID: F07496B3EB3C1762
3 changed files with 3 additions and 6 deletions

View File

@ -29,7 +29,6 @@ const READABLE_OPERATOR = {
const {
errmap,
UV_EAI_MEMORY,
UV_EAI_NODATA,
UV_EAI_NONAME
} = process.binding('uv');
@ -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);

View File

@ -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';

View File

@ -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());