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: fix default nextTick triggerAsyncId #14026

Closed
wants to merge 4 commits into from
Closed

async_hooks: fix default nextTick triggerAsyncId #14026

wants to merge 4 commits into from

Conversation

AndreasMadsen
Copy link
Member

@AndreasMadsen AndreasMadsen commented Jul 1, 2017

Checklist
  • make -j4 test (UNIX), or vcbuild test (Windows) passes
  • tests and/or benchmarks are included
  • commit message follows commit guidelines
Affected core subsystem(s)

async_hooks

In the case where triggerAsyncId is null it should default to the
current executionAsyncId. This worked but as a side-effect the resource
object was changed too.

This fix also makes the null check more strict. EmitInitS is not a
documented API, thus there is no reason to be flexible in its input.

/cc @nodejs/async_hooks

@nodejs-github-bot nodejs-github-bot added async_hooks Issues and PRs related to the async hooks subsystem. process Issues and PRs related to the process subsystem. labels Jul 1, 2017
@AndreasMadsen
Copy link
Member Author

AndreasMadsen commented Jul 1, 2017

In the case where triggerAsyncId is null it should default to the
current executionAsyncId. This worked but as a side-effect the resource
object was changed too.

This fix also makes the null check more strict. EmitInitS is not a
documented API, thus there is no reason to be flexible in its input.
@AndreasMadsen
Copy link
Member Author

I think we should implement this for now. But long term I'm wondering if we should eliminate the polymorphism in nextTick by explitly using initTriggerId().

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.

Makes sense.
Left just some silly nits (ooof I hate to be the nit guy)

@@ -147,7 +152,7 @@ class ActivityCollector {
// events this makes sense for a few tests in which we enable some hooks
// later
if (this._allowNoInit) {
const stub = { uid, type: 'Unknown' };
const stub = { uid, type: 'Unknown', handleIsObject: true };
Copy link
Contributor

Choose a reason for hiding this comment

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

Nit: maybe just isObject? (here and everywhere, obviusly)

Copy link
Member Author

Choose a reason for hiding this comment

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

I would much rather be explicit, so many things could be an object.

@@ -147,7 +152,7 @@ class ActivityCollector {
// events this makes sense for a few tests in which we enable some hooks
Copy link
Contributor

Choose a reason for hiding this comment

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

nit: If you're already here, could you turn this comment to a proper paragraph (capitalization, some punctuation, etc)

@@ -315,13 +315,13 @@ function setupNextTick() {
}

const asyncId = ++async_uid_fields[kAsyncUidCntr];
if (triggerAsyncId === null) {
Copy link
Contributor

Choose a reason for hiding this comment

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

Nit: Since it's argument overload handling, could you move it up, probably just after the if (process._exiting) return

uid,
type,
triggerAsyncId,
// in some cases (Timeout) the handle is a function, thus the usual
Copy link
Contributor

Choose a reason for hiding this comment

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

Nit: (I don't really mind but) start the sentence with a capital I. Also (e.g. `Timeout`)

@@ -0,0 +1,37 @@
'use strict';
Copy link
Contributor

Choose a reason for hiding this comment

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

Nit: style as in https://github.com/nodejs/node/blob/master/doc/guides/writing-tests.md#test-structure (and but the //Flags on the first line 🤷‍♂️

@AndreasMadsen
Copy link
Member Author

AndreasMadsen commented Jul 3, 2017

@AndreasMadsen
Copy link
Member Author

landed in 0fd4c73

addaleax pushed a commit that referenced this pull request Jul 11, 2017
In the case where triggerAsyncId is null it should default to the
current executionAsyncId. This worked but as a side-effect the resource
object was changed too.

This fix also makes the null check more strict. EmitInitS is not a
documented API, thus there is no reason to be flexible in its input.

Ref: #13548 (comment)
PR-URL: #14026
Reviewed-By: Refael Ackermann <[email protected]>
@addaleax addaleax mentioned this pull request Jul 11, 2017
addaleax pushed a commit that referenced this pull request Jul 18, 2017
In the case where triggerAsyncId is null it should default to the
current executionAsyncId. This worked but as a side-effect the resource
object was changed too.

This fix also makes the null check more strict. EmitInitS is not a
documented API, thus there is no reason to be flexible in its input.

Ref: #13548 (comment)
PR-URL: #14026
Reviewed-By: Refael Ackermann <[email protected]>
Fishrock123 pushed a commit that referenced this pull request Jul 19, 2017
In the case where triggerAsyncId is null it should default to the
current executionAsyncId. This worked but as a side-effect the resource
object was changed too.

This fix also makes the null check more strict. EmitInitS is not a
documented API, thus there is no reason to be flexible in its input.

Ref: #13548 (comment)
PR-URL: #14026
Reviewed-By: Refael Ackermann <[email protected]>
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. process Issues and PRs related to the process subsystem.
Projects
None yet
Development

Successfully merging this pull request may close these issues.

3 participants