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

async-hooks,net: ensure asyncId=null if no handle #13938

Closed
wants to merge 4 commits into from

Conversation

baudehlo
Copy link

@baudehlo baudehlo commented Jun 26, 2017

Checklist
  • make -j4 test (UNIX), or vcbuild test (Windows) passes
    • Note this doesn't pass, but that's because master was failing before. The commit I added passes.
  • tests and/or benchmarks are included
  • commit message follows commit guidelines
Affected core subsystem(s)

async-hooks, net

@nodejs-github-bot nodejs-github-bot added the net Issues and PRs related to the net subsystem. label Jun 26, 2017
@baudehlo
Copy link
Author

Fixes #13548

Copy link
Member

@addaleax addaleax left a comment

Choose a reason for hiding this comment

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

Can you make a few edits? Also, it would be perfect if you could include Fixes: https://github.com/nodejs/node/issues/13548 in the commit message itself so that the issue will automatically be closed when this is merged.

Thank you for doing this!

@nodejs/async_hooks

try {
server.getConnections(() => {
assert.ok(true, "No error thrown")
});
Copy link
Member

Choose a reason for hiding this comment

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

Can you indent using 2 spaces? I think our linter complains otherwise.

@@ -0,0 +1,14 @@
'use strict';

const assert = require('assert');
Copy link
Member

Choose a reason for hiding this comment

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

Can you const common = require('../common'); here?


try {
server.getConnections(() => {
assert.ok(true, "No error thrown")
Copy link
Member

Choose a reason for hiding this comment

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

You can just call server.getConnections(common.mustCall()) or server.getConnections(common.mustCall(fn)), that’s a bit shorter (and actually makes sure that the callback gets executed) :)

}
catch (e) {
assert.ok(false, "getConnections threw an error");
}
Copy link
Member

Choose a reason for hiding this comment

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

You don’t need the try/catch, if an error is thrown the test is going to fail anyway because the process crashes with an uncaught exception

Copy link
Author

Choose a reason for hiding this comment

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

OK, would you prefer a comment to that effect then? I was trying to write the test showing the context of what happened before the change.

@addaleax addaleax added the async_hooks Issues and PRs related to the async hooks subsystem. label Jun 26, 2017
Copy link
Contributor

@refack refack left a comment

Choose a reason for hiding this comment

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

LGTM % previous comments (to get linter passing)

@baudehlo
Copy link
Author

Will address the edits. I think adding the Fixes line in a comment works with github too fwiw.

const net = require('net');
const server = net.createServer();

/* This test was based on an error raised by Haraka.
Copy link
Contributor

Choose a reason for hiding this comment

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

The comment is good 👍
Style nit: line comments (//) are prefered.
And replace See: with Ref:

'use strict';

const common = require('../common');
const assert = require('assert');
Copy link
Contributor

Choose a reason for hiding this comment

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

unused assert will fail linter.

@refack
Copy link
Contributor

refack commented Jun 27, 2017

CI: https://ci.nodejs.org/job/node-test-commit/10779/
Lint fail:

not ok 3 - /usr/home/iojs/build/workspace/node-test-linter/test/async-hooks/test-get-connections.js
  ---
  message: '''assert'' is assigned a value but never used.'
  severity: error
  data:
    line: 4
    column: 7
    ruleId: no-unused-vars
  messages:
    - message: Trailing spaces not allowed.
      severity: error
      data:
        line: 10
        column: 1
        ruleId: no-trailing-spaces
  ...

@mscdex
Copy link
Contributor

mscdex commented Jun 27, 2017

I guess this is the kind of change needed for http.Agent as well?

@@ -0,0 +1,11 @@
'use strict';
Copy link
Member

Choose a reason for hiding this comment

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

Hi, please rename the file to test-net-get-connections.js.

@AndreasMadsen
Copy link
Member

AndreasMadsen commented Jul 3, 2017

CI: https://ci.nodejs.org/job/node-test-pull-request/8942/

@baudehlo will you rename the file and add Fixes: https://github.com/nodejs/node/issues/13548 to the commit message. If not, I can do it myself.

@baudehlo
Copy link
Author

baudehlo commented Jul 3, 2017 via email

Matt Sergeant and others added 4 commits July 3, 2017 13:56
If the .listen() hasn't been called on the server, there is no handle
object. In this case use null as the triggerAsyncId.

Fixes: nodejs#13548
@AndreasMadsen
Copy link
Member

Copy link
Member

@AndreasMadsen AndreasMadsen left a comment

Choose a reason for hiding this comment

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

LGTM

Copy link
Contributor

@trevnorris trevnorris left a comment

Choose a reason for hiding this comment

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

Thank you

@AndreasMadsen
Copy link
Member

landed in aa8655a

@tniessen
Copy link
Member

tniessen commented Jul 5, 2017

I think it should have been async_hooks in the commit title. not async-hooks. Just for the future.

@AndreasMadsen
Copy link
Member

@tniessen sorry about that.

addaleax pushed a commit that referenced this pull request Jul 11, 2017
If the .listen() hasn't been called on the server, there is no handle
object. In this case use null as the triggerAsyncId.

Fixes: #13548
PR-URL: #13938
Reviewed-By: James M Snell <jasnell@gmail.com>
Reviewed-By: Refael Ackermann <refack@gmail.com>
Reviewed-By: Trevor Norris <trev.norris@gmail.com>
Reviewed-By: Andreas Madsen <amwebdk@gmail.com>
@addaleax addaleax mentioned this pull request Jul 11, 2017
addaleax pushed a commit that referenced this pull request Jul 18, 2017
If the .listen() hasn't been called on the server, there is no handle
object. In this case use null as the triggerAsyncId.

Fixes: #13548
PR-URL: #13938
Reviewed-By: James M Snell <jasnell@gmail.com>
Reviewed-By: Refael Ackermann <refack@gmail.com>
Reviewed-By: Trevor Norris <trev.norris@gmail.com>
Reviewed-By: Andreas Madsen <amwebdk@gmail.com>
Fishrock123 pushed a commit that referenced this pull request Jul 19, 2017
If the .listen() hasn't been called on the server, there is no handle
object. In this case use null as the triggerAsyncId.

Fixes: #13548
PR-URL: #13938
Reviewed-By: James M Snell <jasnell@gmail.com>
Reviewed-By: Refael Ackermann <refack@gmail.com>
Reviewed-By: Trevor Norris <trev.norris@gmail.com>
Reviewed-By: Andreas Madsen <amwebdk@gmail.com>
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
async_hooks Issues and PRs related to the async hooks subsystem. net Issues and PRs related to the net subsystem.
Projects
None yet
Development

Successfully merging this pull request may close these issues.

9 participants