Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

dns: report out of memory properly #20317

Closed
wants to merge 5 commits into from
Closed
Show file tree
Hide file tree
Changes from 3 commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
5 changes: 1 addition & 4 deletions lib/internal/errors.js
Original file line number Diff line number Diff line change
Expand Up @@ -28,7 +28,6 @@ const READABLE_OPERATOR = {

const {
errmap,
UV_EAI_MEMORY,
UV_EAI_NODATA,
UV_EAI_NONAME
} = process.binding('uv');
Expand Down Expand Up @@ -639,9 +638,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
15 changes: 15 additions & 0 deletions test/parallel/test-dns-memory-error.js
Original file line number Diff line number Diff line change
@@ -0,0 +1,15 @@
// Flags: --expose-internals
'use strict';

// Check that if libuv reports a memory error on a DNS query, that the memory
// error is passed through and not replaced with ENOTFOUND.

require('../common');

const assert = require('assert');
const errors = require('internal/errors');

const { UV_EAI_MEMORY } = process.binding('uv');
const memoryError = errors.dnsException(UV_EAI_MEMORY, 'fhqwhgads');

assert.strictEqual(memoryError.code, 'EAI_MEMORY');
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(250);
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I know you were doing this just to see if the OOM error went away on SmartOS, but I think 256 was chosen specifically because 255 is the maximum length for a hostname. I believe the idea here is to trigger a hostname-too-long error specifically. So this change should not land, I suspect.

const MAX_TRIES = 5;

let errCode = 'ENOTFOUND';
Expand Down