Andreas Madsen
f14ad7d0fa
async_hooks: require parameter in emitBefore
...
Using asyncId as the default triggerAsyncId is wrong. The triggerAsyncId
can actually never be the asyncId.
PR-URL: https://github.com/nodejs/node/pull/14050
Reviewed-By: Trevor Norris <trev.norris@gmail.com >
Reviewed-By: Anna Henningsen <anna@addaleax.net >
2017-07-19 15:02:15 -04:00
Andreas Madsen
8d3b34b3b7
async_hooks: use common emitBefore and emitAfter
...
Timers and nextTick have special emitBefore and emitAfter functions for
historic reasons. These function are not needed any more, thus the
public emitBefore and emitAfter function can be used.
PR-URL: https://github.com/nodejs/node/pull/14050
Reviewed-By: Trevor Norris <trev.norris@gmail.com >
Reviewed-By: Anna Henningsen <anna@addaleax.net >
2017-07-19 15:02:15 -04:00
Andreas Madsen
796881d749
async_hooks: fix default nextTick triggerAsyncId
...
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: https://github.com/nodejs/node/issues/13548#issuecomment-310985270
PR-URL: https://github.com/nodejs/node/pull/14026
Reviewed-By: Refael Ackermann <refack@gmail.com >
2017-07-19 15:02:11 -04:00
Ruben Bridgewater
70dad234ca
async_hooks: reduce duplication with factory
...
PR-URL: https://github.com/nodejs/node/pull/13755
Reviewed-By: Trevor Norris <trev.norris@gmail.com >
Reviewed-By: Refael Ackermann <refack@gmail.com >
Reviewed-By: Andreas Madsen <amwebdk@gmail.com >
2017-07-19 15:02:10 -04:00
Andreas Madsen
3bb4ec80ae
async_hooks: rename currentId and triggerId
...
currentId is renamed to executionAsyncId
triggerId is renamed to triggerAsyncId
AsyncResource.triggerId is renamed to AsyncResource.triggerAsyncId
AsyncHooksGetCurrentId is renamed to AsyncHooksGetExecutionAsyncId
AsyncHooksGetTriggerId is renamed to AsyncHooksGetTriggerAsyncId
PR-URL: https://github.com/nodejs/node/pull/13490
Reviewed-By: Refael Ackermann <refack@gmail.com >
Reviewed-By: Anna Henningsen <anna@addaleax.net >
Reviewed-By: Trevor Norris <trev.norris@gmail.com >
2017-07-11 19:16:37 +02:00
Trevor Norris
2122e2fe89
async_wrap: use kTotals to enable PromiseHook
...
Keep a total of enabled hook callbacks in kTotals. This value is used to
track whether node::PromiseHook (src/async-wrap.cc) should be enabled or
disabled.
Don't enable node::PromiseHook, using enablePromiseHook(), until a hook
has been added. Then, using disablePromiseHook(), disable
node::PromiseHook when all hooks have been disabled.
Need to use a native test in order to check the internal field of the
Promise and check for a PromiseWrap.
PR-URL: https://github.com/nodejs/node/pull/13509
Reviewed-By: Andreas Madsen <amwebdk@gmail.com >
Reviewed-By: Anna Henningsen <anna@addaleax.net >
2017-07-11 19:16:35 +02:00
Trevor Norris
8b57b09c15
Revert "async_hooks: only set up hooks if used"
...
This reverts commit 410b141764 .
PR-URL: https://github.com/nodejs/node/pull/13509
Reviewed-By: Andreas Madsen <amwebdk@gmail.com >
Reviewed-By: Anna Henningsen <anna@addaleax.net >
2017-07-11 19:16:33 +02:00
Anna Henningsen
61c73085ba
async_hooks: minor refactor to callback invocation
...
Re-use the `init` function wherever possible, and move
`try { … } catch` blocks that result in fatal errors to a larger
scope.
Also make the argument order for `init()` consistent in the codebase.
PR-URL: https://github.com/nodejs/node/pull/13419
Reviewed-By: Trevor Norris <trev.norris@gmail.com >
Reviewed-By: Andreas Madsen <amwebdk@gmail.com >
Reviewed-By: Refael Ackermann <refack@gmail.com >
2017-06-10 17:53:22 +02:00
Anna Henningsen
bf61d97742
async_hooks: make sure .{en|dis}able() === this
...
Make sure that `hook.enable()` and `hook.disable()` return `hook`
consistently, as the documentation indicates.
PR-URL: https://github.com/nodejs/node/pull/13418
Reviewed-By: Refael Ackermann <refack@gmail.com >
Reviewed-By: Andreas Madsen <amwebdk@gmail.com >
Reviewed-By: James M Snell <jasnell@gmail.com >
Reviewed-By: Colin Ihrig <cjihrig@gmail.com >
Reviewed-By: Trevor Norris <trev.norris@gmail.com >
2017-06-10 17:53:21 +02:00
David Cai
68e06e6945
test: increase coverage of async_hooks
...
PR-URL: https://github.com/nodejs/node/pull/13336
Reviewed-By: James M Snell <jasnell@gmail.com >
Reviewed-By: Andreas Madsen <amwebdk@gmail.com >
Reviewed-By: Trevor Norris <trev.norris@gmail.com >
2017-06-07 13:32:08 -07:00
Anna Henningsen
3863c3ae66
async_hooks: rename AsyncEvent to AsyncResource
...
`AsyncEvent` is not a good name given its semantics.
PR-URL: https://github.com/nodejs/node/pull/13192
Reviewed-By: Andreas Madsen <amwebdk@gmail.com >
Reviewed-By: James M Snell <jasnell@gmail.com >
Reviewed-By: Jeremiah Senkpiel <fishrock123@rocketmail.com >
Reviewed-By: Colin Ihrig <cjihrig@gmail.com >
2017-05-28 07:03:37 -07:00
Anna Henningsen
e554bb449e
async_hooks: only set up hooks if used
...
PR-URL: https://github.com/nodejs/node/pull/13177
Reviewed-By: James M Snell <jasnell@gmail.com >
Reviewed-By: Andreas Madsen <amwebdk@gmail.com >
Reviewed-By: Jeremiah Senkpiel <fishrock123@rocketmail.com >
Reviewed-By: Colin Ihrig <cjihrig@gmail.com >
2017-05-28 07:00:43 -07:00
Shadowbeetle
6fb27af70a
async_hooks: add constructor check to async-hooks
...
This fixes the async_hooks.AsyncHook constructor such that it throws an
error when provided with falsy values other than undefined.
PR-URL: https://github.com/nodejs/node/pull/13096
Reviewed-By: Anna Henningsen <anna@addaleax.net >
Reviewed-By: Colin Ihrig <cjihrig@gmail.com >
Reviewed-By: Refael Ackermann <refack@gmail.com >
Reviewed-By: Andreas Madsen <amwebdk@gmail.com >
2017-05-21 22:04:15 +02:00
Trevor Norris
4a7233c178
lib: implement async_hooks API in core
...
Implement async_hooks support in the following:
* fatalException handler
* process.nextTick
* Timers
* net/dgram/http
PR-URL: https://github.com/nodejs/node/pull/12892
Ref: https://github.com/nodejs/node/pull/11883
Ref: https://github.com/nodejs/node/pull/8531
Reviewed-By: Andreas Madsen <amwebdk@gmail.com >
Reviewed-By: Anna Henningsen <anna@addaleax.net >
Reviewed-By: Sam Roberts <vieuxtech@gmail.com >
Reviewed-By: Matteo Collina <matteo.collina@gmail.com >
Reviewed-By: Refael Ackermann <refack@gmail.com >
Reviewed-By: James M Snell <jasnell@gmail.com >
Reviewed-By: Jeremiah Senkpiel <fishrock123@rocketmail.com >
2017-05-10 22:22:29 +02:00
Trevor Norris
7e3a3c962f
async_hooks: initial async_hooks implementation
...
Fill this commit messsage with more details about the change once all
changes are rebased.
* Add lib/async_hooks.js
* Add JS methods to AsyncWrap for handling the async id stack
* Introduce AsyncReset() so that JS functions can reset the id and again
trigger the init hooks, allow AsyncWrap::Reset() to be called from JS
via asyncReset().
* Add env variable to test additional things in test/common.js
PR-URL: https://github.com/nodejs/node/pull/12892
Ref: https://github.com/nodejs/node/pull/11883
Ref: https://github.com/nodejs/node/pull/8531
Reviewed-By: Andreas Madsen <amwebdk@gmail.com >
Reviewed-By: Anna Henningsen <anna@addaleax.net >
Reviewed-By: Sam Roberts <vieuxtech@gmail.com >
Reviewed-By: Matteo Collina <matteo.collina@gmail.com >
Reviewed-By: Refael Ackermann <refack@gmail.com >
Reviewed-By: James M Snell <jasnell@gmail.com >
Reviewed-By: Jeremiah Senkpiel <fishrock123@rocketmail.com >
2017-05-10 22:22:26 +02:00