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

net: support DNS hints in createConnection() #6000

Merged
merged 1 commit into from Apr 1, 2016
Merged

Conversation

cjihrig
Copy link
Contributor

@cjihrig cjihrig commented Apr 1, 2016

Pull Request check-list

Please make sure to review and check all of these items:

  • Does make -j8 test (UNIX) or vcbuild test nosign (Windows) pass with
    this change (including linting)?
  • Is the commit message formatted according to CONTRIBUTING.md?
  • Is a documentation update included (if this change modifies
    existing APIs, or introduces new ones)?

Affected core subsystem(s)

net

Description of change

This commit adds support for passing DNS lookup hints to createConnection().

This PR is semver minor, but I'd like to toss out the idea of a semver major change where no DNS hints are implicitly set. Instead, users could specify hints if necessary. My motivation is a number of issues related to varying support of V4MAPPED. Thoughts @bnoordhuis / @indutny?

@cjihrig cjihrig added net Issues and PRs related to the net subsystem. semver-minor PRs that contain new features and should be released in the next minor version. labels Apr 1, 2016
@@ -1,6 +1,7 @@
'use strict';
var common = require('../common');
Copy link
Member

Choose a reason for hiding this comment

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

maybe make these const since you're in here anyway?

@jasnell
Copy link
Member

jasnell commented Apr 1, 2016

Generally that sounds ok to me, but can you describe the issues a bit?

@cjihrig
Copy link
Contributor Author

cjihrig commented Apr 1, 2016

The issue is that it isn't supported on all platforms and we end up with hacks just to set the flag on connections. In most cases this probably isn't needed at all, and being explicit would probably be better.

Some reference issues:
nodejs/node-v0.x-archive#8540
#3800
#337
#3771
#5436

@bnoordhuis
Copy link
Member

LGTM. IIRC, the deeper issue is that we set AI_V4MAPPED indiscriminately instead of only when family === 6.

@cjihrig
Copy link
Contributor Author

cjihrig commented Apr 1, 2016

@bnoordhuis yea, that was one of the issues. It's also not supported on FreeBSD and Android. Would you be OK with making hints explicit in a semver major?

@bnoordhuis
Copy link
Member

You mean making it a required argument period or required when you want to set AI_V4MAPPED? The latter is okay, I think, although there may be some fallout and it pushes the burden of dealing with platform inconsistencies to user land.

@cjihrig
Copy link
Contributor Author

cjihrig commented Apr 1, 2016

You mean making it a required argument period or required when you want to set AI_V4MAPPED?

I meant removing this block and making hints strictly optional.

I suppose another alternative is to make the change suggested in #5436 and only set V4MAPPED when the flag is supported by the platform and the family is explicitly set to 6.

This commit adds support for passing DNS lookup hints to
createConnection().

PR-URL: nodejs#6000
Reviewed-By: Ben Noordhuis <info@bnoordhuis.nl>
Reviewed-By: James M Snell <jasnell@gmail.com>
@bnoordhuis
Copy link
Member

I meant removing this block and making hints strictly optional.

Right. I think it's a good idea in that it means less implicit behavior and more mechanism over policy. However, we've been shipping this code for a while so we should test that it doesn't break to much. @thealphanerd can probably help with that.

@cjihrig
Copy link
Contributor Author

cjihrig commented Apr 1, 2016

OK, I'll put together a PR that can be run through CITGM.

@cjihrig
Copy link
Contributor Author

cjihrig commented Apr 1, 2016

CI for this PR: https://ci.nodejs.org/job/node-test-pull-request/2123/

UPDATE: First run had one failure, which may have been flakey. Trying again: https://ci.nodejs.org/job/node-test-pull-request/2125/

@jasnell
Copy link
Member

jasnell commented Apr 1, 2016

@cjihrig .. thanks .. yeah, I think I'm +1 on it also. this change LGTM if CI is green. Will watch for the other PR!

@cjihrig cjihrig mentioned this pull request Apr 1, 2016
@cjihrig cjihrig merged this pull request into nodejs:master Apr 1, 2016
@cjihrig cjihrig deleted the hints branch April 1, 2016 21:04
@cjihrig
Copy link
Contributor Author

cjihrig commented Apr 1, 2016

Landed in 39de601

cjihrig added a commit that referenced this pull request Apr 1, 2016
This commit adds support for passing DNS lookup hints to
createConnection().

PR-URL: #6000
Reviewed-By: Ben Noordhuis <info@bnoordhuis.nl>
Reviewed-By: James M Snell <jasnell@gmail.com>
@MylesBorins
Copy link
Member

@cjihrig the tests are failing when this commit is cherry-picked to v5.x

assert.js:330
    throw actual;
    ^

TypeError: invalid argument: hints must use valid flags
    at lookup (dns.js:129:13)
    at lookupAndConnect (net.js:963:3)
    at Socket.connect (net.js:903:5)
    at Object.exports.connect.exports.createConnection (net.js:69:35)
    at /Users/thealphanerd/code/node/master/test/parallel/test-net-create-connection.js:26:11
    at _tryBlock (assert.js:296:5)
    at _throws (assert.js:315:12)
    at Function.assert.throws (assert.js:338:3)
    at fail (/Users/thealphanerd/code/node/master/test/parallel/test-net-create-connection.js:25:12)
    at Server.<anonymous> (/Users/thealphanerd/code/node/master/test/parallel/test-net-create-connection.js:92:3)

@cjihrig
Copy link
Contributor Author

cjihrig commented Apr 5, 2016

Looks like the error message in lib/dns.js is different across the branches:
master: https://github.com/nodejs/node/blob/master/lib/dns.js#L131
v5.x: https://github.com/nodejs/node/blob/v5.x/lib/dns.js#L129

Can you give that a shot in the test?

@MylesBorins
Copy link
Member

@cjihrig I already tried updating the error message. The error as included above was the new test failing

cjihrig added a commit to cjihrig/node that referenced this pull request Apr 5, 2016
This commit adds support for passing DNS lookup hints to
createConnection().

PR-URL: nodejs#6000
Reviewed-By: Ben Noordhuis <info@bnoordhuis.nl>
Reviewed-By: James M Snell <jasnell@gmail.com>

Conflicts:
	test/parallel/test-net-create-connection.js
@cjihrig
Copy link
Contributor Author

cjihrig commented Apr 5, 2016

@thealphanerd worked fine for me. See #6061

MylesBorins pushed a commit that referenced this pull request Apr 15, 2016
This commit adds support for passing DNS lookup hints to
createConnection().

PR-URL: #6000
Reviewed-By: Ben Noordhuis <info@bnoordhuis.nl>
Reviewed-By: James M Snell <jasnell@gmail.com>

Conflicts:
	test/parallel/test-net-create-connection.js
MylesBorins pushed a commit that referenced this pull request Apr 21, 2016
Buffer:
  * Buffer.prototype.compare can now compare sub-ranges of two Buffers
   (James M Snell) #5880

deps:
  * update to http-parser 2.7.0
    (Fedor Indutny) #6279
  * update ESLint to 2.7.0
    (silverwind) #6132

net:
  * adds support for passing DNS lookup hints to createConnection()
    (Colin Ihrig) #6000

node:
  * Make the builtin libraries available for the --eval and --print
    CLI options
    (Anna Henningsen) #6207

npm:
  * upgrade npm to 3.8.6
    (Kat Marchán) #6153

repl:
  * Pressing enter in the repl will repeat the last command by default
    if no input has been received. This behaviour was in node
    previously and was not removed intentionally.
    (Rich Trott) #6090

src:
  * add SIGINFO to supported signals
    (James Reggio) #6093

streams:
  * Fix a regression that caused by net streams requesting multiple
    chunks synchronously when combined with cork/uncork
    (Matteo Collina) #6164

zlib:
  * The flushing flag is now configurable allowing for decompression
    of partial data
    (Anna Henningsen) #6069
@MylesBorins MylesBorins mentioned this pull request Apr 21, 2016
@MylesBorins MylesBorins mentioned this pull request Apr 21, 2016
MylesBorins pushed a commit that referenced this pull request Apr 21, 2016
Buffer:
  * Buffer.prototype.compare can now compare sub-ranges of two Buffers
   (James M Snell) #5880

deps:
  * update to http-parser 2.7.0
    (Fedor Indutny) #6279
  * update ESLint to 2.7.0
    (silverwind) #6132

net:
  * adds support for passing DNS lookup hints to createConnection()
    (Colin Ihrig) #6000

node:
  * Make the builtin libraries available for the --eval and --print
    CLI options
    (Anna Henningsen) #6207

npm:
  * upgrade npm to 3.8.6
    (Kat Marchán) #6153

repl:
  * Pressing enter in the repl will repeat the last command by default
    if no input has been received. This behavior was in node
    previously and was not removed intentionally.
    (Rich Trott) #6090

src:
  * add SIGINFO to supported signals
    (James Reggio) #6093

streams:
  * Fix a regression that caused by net streams requesting multiple
    chunks synchronously when combined with cork/uncork
    (Matteo Collina) #6164

zlib:
  * The flushing flag is now configurable allowing for decompression
    of partial data
    (Anna Henningsen) #6069
MylesBorins pushed a commit that referenced this pull request Apr 21, 2016
Buffer:
  * Buffer.prototype.compare can now compare sub-ranges of two Buffers
   (James M Snell) #5880

deps:
  * update to http-parser 2.7.0
    (Fedor Indutny) #6279
  * update ESLint to 2.7.0
    (silverwind) #6132

net:
  * adds support for passing DNS lookup hints to createConnection()
    (Colin Ihrig) #6000

node:
  * Make the builtin libraries available for the --eval and --print
    CLI options
    (Anna Henningsen) #6207

npm:
  * upgrade npm to 3.8.6
    (Kat Marchán) #6153

repl:
  * Pressing enter in the repl will repeat the last command by default
    if no input has been received. This behaviour was in node
    previously and was not removed intentionally.
    (Rich Trott) #6090

src:
  * add SIGINFO to supported signals
    (James Reggio) #6093

streams:
  * Fix a regression that caused by net streams requesting multiple
    chunks synchronously when combined with cork/uncork
    (Matteo Collina) #6164

zlib:
  * The flushing flag is now configurable allowing for decompression
    of partial data
    (Anna Henningsen) #6069

PR-URL: #6322
MylesBorins pushed a commit that referenced this pull request Apr 21, 2016
Buffer:
  * Buffer.prototype.compare can now compare sub-ranges of two Buffers
   (James M Snell) #5880

deps:
  * update to http-parser 2.7.0
    (Fedor Indutny) #6279
  * update ESLint to 2.7.0
    (silverwind) #6132

net:
  * adds support for passing DNS lookup hints to createConnection()
    (Colin Ihrig) #6000

node:
  * Make the builtin libraries available for the --eval and --print
    CLI options
    (Anna Henningsen) #6207

npm:
  * upgrade npm to 3.8.6
    (Kat Marchán) #6153

repl:
  * Pressing enter in the repl will repeat the last command by default
    if no input has been received. This behaviour was in node
    previously and was not removed intentionally.
    (Rich Trott) #6090

src:
  * add SIGINFO to supported signals
    (James Reggio) #6093

streams:
  * Fix a regression that caused by net streams requesting multiple
    chunks synchronously when combined with cork/uncork
    (Matteo Collina) #6164

zlib:
  * The flushing flag is now configurable allowing for decompression
    of partial data
    (Anna Henningsen) #6069

PR-URL: #6322
joelostrowski pushed a commit to joelostrowski/node that referenced this pull request Apr 25, 2016
Buffer:
  * Buffer.prototype.compare can now compare sub-ranges of two Buffers
   (James M Snell) nodejs#5880

deps:
  * update to http-parser 2.7.0
    (Fedor Indutny) nodejs#6279
  * update ESLint to 2.7.0
    (silverwind) nodejs#6132

net:
  * adds support for passing DNS lookup hints to createConnection()
    (Colin Ihrig) nodejs#6000

node:
  * Make the builtin libraries available for the --eval and --print
    CLI options
    (Anna Henningsen) nodejs#6207

npm:
  * upgrade npm to 3.8.6
    (Kat Marchán) nodejs#6153

repl:
  * Pressing enter in the repl will repeat the last command by default
    if no input has been received. This behaviour was in node
    previously and was not removed intentionally.
    (Rich Trott) nodejs#6090

src:
  * add SIGINFO to supported signals
    (James Reggio) nodejs#6093

streams:
  * Fix a regression that caused by net streams requesting multiple
    chunks synchronously when combined with cork/uncork
    (Matteo Collina) nodejs#6164

zlib:
  * The flushing flag is now configurable allowing for decompression
    of partial data
    (Anna Henningsen) nodejs#6069

PR-URL: nodejs#6322
jasnell pushed a commit that referenced this pull request Apr 26, 2016
Buffer:
  * Buffer.prototype.compare can now compare sub-ranges of two Buffers
   (James M Snell) #5880

deps:
  * update to http-parser 2.7.0
    (Fedor Indutny) #6279
  * update ESLint to 2.7.0
    (silverwind) #6132

net:
  * adds support for passing DNS lookup hints to createConnection()
    (Colin Ihrig) #6000

node:
  * Make the builtin libraries available for the --eval and --print
    CLI options
    (Anna Henningsen) #6207

npm:
  * upgrade npm to 3.8.6
    (Kat Marchán) #6153

repl:
  * Pressing enter in the repl will repeat the last command by default
    if no input has been received. This behaviour was in node
    previously and was not removed intentionally.
    (Rich Trott) #6090

src:
  * add SIGINFO to supported signals
    (James Reggio) #6093

streams:
  * Fix a regression that caused by net streams requesting multiple
    chunks synchronously when combined with cork/uncork
    (Matteo Collina) #6164

zlib:
  * The flushing flag is now configurable allowing for decompression
    of partial data
    (Anna Henningsen) #6069

PR-URL: #6322
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
net Issues and PRs related to the net subsystem. semver-minor PRs that contain new features and should be released in the next minor version.
Projects
None yet
Development

Successfully merging this pull request may close these issues.

None yet

4 participants