Skip to content

Commit a158d41

Browse files
committed
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: #20317 Reviewed-By: Ben Noordhuis <info@bnoordhuis.nl> Reviewed-By: Colin Ihrig <cjihrig@gmail.com> Reviewed-By: Trivikram Kamat <trivikr.dev@gmail.com>
1 parent 283a967 commit a158d41

File tree

3 files changed

+3
-6
lines changed

3 files changed

+3
-6
lines changed

lib/internal/errors.js

+1-4
Original file line numberDiff line numberDiff line change
@@ -29,7 +29,6 @@ const READABLE_OPERATOR = {
2929

3030
const {
3131
errmap,
32-
UV_EAI_MEMORY,
3332
UV_EAI_NODATA,
3433
UV_EAI_NONAME
3534
} = process.binding('uv');
@@ -640,9 +639,7 @@ function dnsException(code, syscall, hostname) {
640639
if (typeof code === 'number') {
641640
// FIXME(bnoordhuis) Remove this backwards compatibility nonsense and pass
642641
// the true error to the user. ENOTFOUND is not even a proper POSIX error!
643-
if (code === UV_EAI_MEMORY ||
644-
code === UV_EAI_NODATA ||
645-
code === UV_EAI_NONAME) {
642+
if (code === UV_EAI_NODATA || code === UV_EAI_NONAME) {
646643
code = 'ENOTFOUND'; // Fabricated error name.
647644
} else {
648645
code = lazyInternalUtil().getSystemErrorName(code);

test/parallel/test-http-dns-error.js

+1-1
Original file line numberDiff line numberDiff line change
@@ -29,7 +29,7 @@ const assert = require('assert');
2929
const http = require('http');
3030
const https = require('https');
3131

32-
const host = '*'.repeat(256);
32+
const host = '*'.repeat(64);
3333
const MAX_TRIES = 5;
3434

3535
let errCode = 'ENOTFOUND';

test/parallel/test-net-dns-error.js

+1-1
Original file line numberDiff line numberDiff line change
@@ -25,7 +25,7 @@ const common = require('../common');
2525
const assert = require('assert');
2626
const net = require('net');
2727

28-
const host = '*'.repeat(256);
28+
const host = '*'.repeat(64);
2929
const errCode = common.isOpenBSD ? 'EAI_FAIL' : 'ENOTFOUND';
3030

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

0 commit comments

Comments
 (0)