-
Notifications
You must be signed in to change notification settings - Fork 29.8k
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 rename #14152
Async hooks rename #14152
Conversation
@@ -18,8 +18,8 @@ assert.throws(() => new AsyncResource('invalid_trigger_id', null), | |||
/^RangeError: triggerAsyncId must be an unsigned integer$/); | |||
|
|||
assert.strictEqual( | |||
typeof new AsyncResource('default_trigger_id').triggerAsyncId(), |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
This change wasn't needed. But when I looked for the AsyncResource('default_trigger_id')
test, I found that it could be made more strict.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
nits
|
||
if (typeof type !== 'string' || type.length <= 0) | ||
throw new TypeError('type must be a string with length > 0'); | ||
constructor(type, triggerAsyncId = initTriggerId()) { |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
So just an FYI since this effectively changes the signature of the ctor (now AsyncResource.length == 1
it would have been some do consider it semver-major
, but since this congruent with the docs, I'd call this a bug fix.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Also this is still officially experimental, which should give us more flexibility.
typeof new AsyncResource('default_trigger_id').triggerAsyncId(), | ||
'number' | ||
new AsyncResource('default_trigger_id').triggerAsyncId(), | ||
async_hooks.executionAsyncId() | ||
); | ||
|
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Could you add assert.strinctEqual(AsyncResource.length, 1);
Retracted
I’m strongly against considering changes semver-major because they modify the value of (edit: and, by extension, we should not need to test the value of |
I agree, but some do consider it as such 🤷♂️ Should bring it up with the release team or the CTC. |
There were a huge amount of unrelated CI failures. It looks like most of it have been fixed in master now. I have rebased on master, hopefully that will fix it.
|
@@ -4,8 +4,14 @@ require('../common'); | |||
// This tests that AsyncResource throws an error if bad parameters are passed | |||
|
|||
const assert = require('assert'); | |||
const async_hooks = require('async_hooks'); | |||
const AsyncResource = require('async_hooks').AsyncResource; |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
nit: this looks a little odd syntactically. maybe something like:
const async_hooks = require('async_hooks');
const { AsyncResource } = async_hooks;
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Have a non-blocking nit. Please don't forget to squash the two commits, and maybe add a message body with more explanation.
Really, you want the two commits squashed? Logically they are very completely separate. |
@AndreasMadsen No. It's a friendly reminder to make sure the commit
is squashed into whatever commit it belongs. It's also not necessarily a reminder for you, but whomever it is that lands the PR. |
I fixed the nit and added some more text in the commit message. If the CI is green I will just go ahead and merge. |
There are two categories of emit functions in async_hooks, those used by c++ (native) and those used by JavaScript (script). Previously these were named N for native and S for script. Finally, there was an odd case where emitInitN was called just init. This makes it more explicit by using the names emitInitNative and emitInitScript. The other emit functions are also renamed.
AsyncResource previously called emitInitNative. Since AsyncResource is just an abstraction on top of the emitEventScript functions, it should call emitInitScript instead.
Fixed a small merge conflict. |
@AndreasMadsen Thanks for the two thorough git commit messages. |
There are two categories of emit functions in async_hooks, those used by c++ (native) and those used by JavaScript (script). Previously these were named N for native and S for script. Finally, there was an odd case where emitInitN was called just init. This makes it more explicit by using the names emitInitNative and emitInitScript. The other emit functions are also renamed. PR-URL: #14152 Reviewed-By: Refael Ackermann <refack@gmail.com> Reviewed-By: Trevor Norris <trev.norris@gmail.com> Reviewed-By: James M Snell <jasnell@gmail.com> Reviewed-By: Anna Henningsen <anna@addaleax.net>
AsyncResource previously called emitInitNative. Since AsyncResource is just an abstraction on top of the emitEventScript functions, it should call emitInitScript instead. PR-URL: #14152 Reviewed-By: Refael Ackermann <refack@gmail.com> Reviewed-By: Trevor Norris <trev.norris@gmail.com> Reviewed-By: James M Snell <jasnell@gmail.com> Reviewed-By: Anna Henningsen <anna@addaleax.net>
There are two categories of emit functions in async_hooks, those used by c++ (native) and those used by JavaScript (script). Previously these were named N for native and S for script. Finally, there was an odd case where emitInitN was called just init. This makes it more explicit by using the names emitInitNative and emitInitScript. The other emit functions are also renamed. PR-URL: #14152 Reviewed-By: Refael Ackermann <refack@gmail.com> Reviewed-By: Trevor Norris <trev.norris@gmail.com> Reviewed-By: James M Snell <jasnell@gmail.com> Reviewed-By: Anna Henningsen <anna@addaleax.net>
AsyncResource previously called emitInitNative. Since AsyncResource is just an abstraction on top of the emitEventScript functions, it should call emitInitScript instead. PR-URL: #14152 Reviewed-By: Refael Ackermann <refack@gmail.com> Reviewed-By: Trevor Norris <trev.norris@gmail.com> Reviewed-By: James M Snell <jasnell@gmail.com> Reviewed-By: Anna Henningsen <anna@addaleax.net>
Checklist
make -j4 test
(UNIX), orvcbuild test
(Windows) passesAffected core subsystem(s)
async_hooks
Rename
init
toemitInitNative
and allemit*S
toemit*Script
. I know some are against these purely stylish changes so I included a small consistency fix toAsyncResource
andemitInit
that is much more obvious with the renames.