summaryrefslogtreecommitdiff
path: root/lib/async_hooks.js
AgeCommit message (Collapse)Author
2019-11-30lib: use static Number properties from primordialsMichaël Zasso
PR-URL: https://github.com/nodejs/node/pull/30686 Reviewed-By: Trivikram Kamat <trivikr.dev@gmail.com> Reviewed-By: Anna Henningsen <anna@addaleax.net>
2019-11-25lib: flatten access to primordialsMichaël Zasso
Store all primordials as properties of the primordials object. Static functions are prefixed by the constructor's name and prototype methods are prefixed by the constructor's name followed by "Prototype". For example: primordials.Object.keys becomes primordials.ObjectKeys. PR-URL: https://github.com/nodejs/node/pull/30610 Refs: https://github.com/nodejs/node/issues/29766 Reviewed-By: Anna Henningsen <anna@addaleax.net> Reviewed-By: Matteo Collina <matteo.collina@gmail.com> Reviewed-By: Colin Ihrig <cjihrig@gmail.com> Reviewed-By: Trivikram Kamat <trivikr.dev@gmail.com>
2019-10-26async_hooks: only emit `after` for AsyncResource if stack not emptyAnna Henningsen
We clear the async id stack inside the uncaught exception handler and emit `after` events in the process, so we should not emit `after` a second time from the `runInAsyncScope()` code. This should match the behaviour we have in C++. Fixes: https://github.com/nodejs/node/issues/30080 PR-URL: https://github.com/nodejs/node/pull/30087 Reviewed-By: Gus Caplan <me@gus.host> Reviewed-By: Anto Aravinth <anto.aravinth.cse@gmail.com>
2019-06-10process: improve queueMicrotask performanceAnatoli Papirovski
Optimize the hot code paths of queueMicrotask by not creating unnecessary objects, not looking up properties on frozen primordials, etc. PR-URL: https://github.com/nodejs/node/pull/28093 Reviewed-By: Ruben Bridgewater <ruben@bridgewater.de> Reviewed-By: Gus Caplan <me@gus.host> Reviewed-By: Matteo Collina <matteo.collina@gmail.com>
2019-04-05async_hooks: improve AsyncResource performanceAnatoli Papirovski
Accessing symbols is generally quite expensive and so is emitInit, only do both when actually required. PR-URL: https://github.com/nodejs/node/pull/27032 Reviewed-By: Gus Caplan <me@gus.host> Reviewed-By: Ruben Bridgewater <ruben@bridgewater.de> Reviewed-By: James M Snell <jasnell@gmail.com>
2019-04-03lib: force using primordials for JSON, Math and ReflectMichaël Zasso
Use the "no-restricted-globals" ESLint rule to lint for it. PR-URL: https://github.com/nodejs/node/pull/27027 Reviewed-By: Anna Henningsen <anna@addaleax.net> Reviewed-By: Joyee Cheung <joyeec9h3@gmail.com> Reviewed-By: Colin Ihrig <cjihrig@gmail.com> Reviewed-By: Ruben Bridgewater <ruben@bridgewater.de> Reviewed-By: Gus Caplan <me@gus.host> Reviewed-By: Luigi Pinca <luigipinca@gmail.com>
2019-03-18async_hooks: remove deprecated emitBefore and emitAfterMatteo Collina
AsyncResource.emitBefore and AsyncResource.emitAfter have been deprecated in https://github.com/nodejs/node/pull/18632. This PR removes it all. This commit also updates some embedder tests to use internal APIs. The conditions are still possible for Node.js core developers but not for end users. PR-URL: https://github.com/nodejs/node/pull/26530 Reviewed-By: Ruben Bridgewater <ruben@bridgewater.de> Reviewed-By: Anna Henningsen <anna@addaleax.net> Reviewed-By: Ali Ijaz Sheikh <ofrobots@google.com> Reviewed-By: Benedikt Meurer <benedikt.meurer@gmail.com> Reviewed-By: Yang Guo <yangguo@chromium.org> Reviewed-By: Andreas Madsen <amwebdk@gmail.com> Reviewed-By: James M Snell <jasnell@gmail.com>
2018-12-17doc,lib,test: capitalize comment sentencesRuben Bridgewater
This activates the eslint capitalize comment rule for comments above 50 characters. PR-URL: https://github.com/nodejs/node/pull/24996 Reviewed-By: Ujjwal Sharma <usharma1998@gmail.com> Reviewed-By: Anna Henningsen <anna@addaleax.net> Reviewed-By: Sakthipriyan Vairamani <thechargingvolcano@gmail.com> Reviewed-By: James M Snell <jasnell@gmail.com>
2018-08-07lib: extract validateString validatorJon Moss
Pulls out a common argument validator to `internal/validators` PR-URL: https://github.com/nodejs/node/pull/22101 Reviewed-By: Joyee Cheung <joyeec9h3@gmail.com> Reviewed-By: Michaël Zasso <targos@protonmail.com> Reviewed-By: Trivikram Kamat <trivikr.dev@gmail.com> Reviewed-By: Colin Ihrig <cjihrig@gmail.com> Reviewed-By: Anatoli Papirovski <apapirovski@mac.com> Reviewed-By: Luigi Pinca <luigipinca@gmail.com> Reviewed-By: James M Snell <jasnell@gmail.com>
2018-03-25lib: always show ERR_INVALID_ARG_TYPE received partRuben Bridgewater
This makes a effort to make sure all of these errors will actually also show the received input. On top of that it refactors a few tests for better maintainability. It will also change the returned type to always be a simple typeof instead of special handling null. PR-URL: https://github.com/nodejs/node/pull/19445 Reviewed-By: James M Snell <jasnell@gmail.com> Reviewed-By: Matteo Collina <matteo.collina@gmail.com> Reviewed-By: Joyee Cheung <joyeec9h3@gmail.com> Reviewed-By: Anna Henningsen <anna@addaleax.net>
2018-03-18async_hooks: remove async_wrap from async_hooks.jsDaniel Bevenius
This commit removes the builtin async_wrap module from lib/async_hooks.js. The motivation for this is that lib/async_hooks.js requires lib/internal/async_hooks which also binds async_wrap. Instead of lib/async_hooks.js also binding async_wrap it now only has to require the internal async_hooks and access it's exports. There might be a very good reason for doing it the current way but the reason is not obvious to me. Hopefully someone can shed some light on this. PR-URL: https://github.com/nodejs/node/pull/19368 Reviewed-By: James M Snell <jasnell@gmail.com> Reviewed-By: Anatoli Papirovski <apapirovski@mac.com> Reviewed-By: Andreas Madsen <amwebdk@gmail.com> Reviewed-By: Colin Ihrig <cjihrig@gmail.com> Reviewed-By: Anna Henningsen <anna@addaleax.net> Reviewed-By: Ali Ijaz Sheikh <ofrobots@google.com> Reviewed-By: Luigi Pinca <luigipinca@gmail.com>
2018-03-11async_hooks: don't set hook_fields[kTotals] to 0Daniel Bevenius
This commit removes the setting of hook_field[kTotals] to szero in AsyncHook's enable function. As far as I can tell this would not be required if the setting of this field is done with the assignment operator instead of using the addition assignment operator. PR-URL: https://github.com/nodejs/node/pull/19219 Reviewed-By: Anna Henningsen <anna@addaleax.net> Reviewed-By: James M Snell <jasnell@gmail.com>
2018-03-05lib: port errors to new systemMichaël Zasso
This is a first batch of updates that touches non-underscored modules in lib. PR-URL: https://github.com/nodejs/node/pull/19034 Reviewed-By: James M Snell <jasnell@gmail.com> Reviewed-By: Ruben Bridgewater <ruben@bridgewater.de> Reviewed-By: Joyee Cheung <joyeec9h3@gmail.com>
2018-02-28src: fix error message in async_hooks constructorDaniel Bevenius
There are two minor issues in the AsyncHook constructor, if the object passed in has an after and/or destroy property that are not functions the errors thrown will still be: TypeError [ERR_ASYNC_CALLBACK]: before must be a function This commit updates the code and adds a unit test. PR-URL: https://github.com/nodejs/node/pull/19000 Reviewed-By: Colin Ihrig <cjihrig@gmail.com> Reviewed-By: James M Snell <jasnell@gmail.com> Reviewed-By: Matheus Marchini <matheus@sthima.com> Reviewed-By: Tiancheng "Timothy" Gu <timothygu99@gmail.com>
2018-02-16async_hooks: clean up usage in internal codeAnatoli Papirovski
Instead of exposing internals of async_hooks & async_wrap throughout the code base, create necessary helper methods within the internal async_hooks that allows easy usage by Node.js internals. This stops every single internal user of async_hooks from importing a ton of functions, constants and internal Aliased Buffers from C++ async_wrap. Adds functions initHooksExist, afterHooksExist, and destroyHooksExist to determine whether the related emit methods need to be triggered. Adds clearDefaultTriggerAsyncId and clearAsyncIdStack on the JS side as an alternative to always calling C++. Moves async_id_symbol and trigger_async_id_symbol to internal async_hooks as they are never used in C++. Renames newUid to newAsyncId for added clarity of its purpose. Adjusts usage throughout the codebase, as well as in a couple of tests. PR-URL: https://github.com/nodejs/node/pull/18720 Reviewed-By: James M Snell <jasnell@gmail.com> Reviewed-By: Ali Ijaz Sheikh <ofrobots@google.com> Reviewed-By: Anna Henningsen <anna@addaleax.net>
2018-02-12lib: provide proper deprecation codeRuben Bridgewater
Refs: https://github.com/nodejs/node/pull/18513 PR-URL: https://github.com/nodejs/node/pull/18694 Refs: https://github.com/nodejs/node/pull/18513 Reviewed-By: Ali Ijaz Sheikh <ofrobots@google.com> Reviewed-By: Colin Ihrig <cjihrig@gmail.com> Reviewed-By: Jeremiah Senkpiel <fishrock123@rocketmail.com> Reviewed-By: Luigi Pinca <luigipinca@gmail.com>
2018-02-09async_hooks: deprecate unsafe emit{Before,After}Ali Ijaz Sheikh
The emit{Before,After} APIs in AsyncResource are problematic. * emit{Before,After} are named to suggest that the only thing they do is emit the before and after hooks. However, they in fact, mutate the current execution context. * They must be properly nested. Failure to do so by user code leads to catastrophic (unrecoverable) exceptions. It is very easy for the users to forget that they must be using a try/finally block around the code that must be surrounded by these operations. Even the example provided in the official docs makes this mistake. Failing to use a finally can lead to a catastrophic crash if the callback ends up throwing. This change provides a safer `runInAsyncScope` API as an alternative and deprecates emit{Before,After}. PR-URL: https://github.com/nodejs/node/pull/18513 Reviewed-By: James M Snell <jasnell@gmail.com> Reviewed-By: Anna Henningsen <anna@addaleax.net> Reviewed-By: Andreas Madsen <amwebdk@gmail.com>
2017-12-19async_hooks: rename initTriggerIdAndreas Madsen
rename initTriggerId to defaultTriggerAsyncId such it matches the rest of our naming. PR-URL: https://github.com/nodejs/node/pull/17273 Reviewed-By: Matteo Collina <matteo.collina@gmail.com> Reviewed-By: James M Snell <jasnell@gmail.com>
2017-11-22async_hooks: remove deprecated APIAndreas Madsen
PR-URL: https://github.com/nodejs/node/pull/17147 Refs: https://github.com/nodejs/node/pull/16972 Reviewed-By: James M Snell <jasnell@gmail.com> Reviewed-By: Colin Ihrig <cjihrig@gmail.com>
2017-11-20async_hooks: deprecate undocumented APIAndreas Madsen
PR-URL: https://github.com/nodejs/node/pull/16972 Refs: https://github.com/nodejs/node/issues/14328 Refs: https://github.com/nodejs/node/issues/15572 Reviewed-By: Anna Henningsen <anna@addaleax.net>
2017-11-16async_hooks: add destroy event for gced AsyncResourcesSebastian Mayr
In cases where libraries create AsyncResources which may be emitting more events depending on usage, the only way to ensure that destroy is called properly is by calling it when the resource gets garbage collected. Fixes: https://github.com/nodejs/node/issues/16153 PR-URL: https://github.com/nodejs/node/pull/16998 Fixes: https://github.com/nodejs/node/issues/16153 Reviewed-By: Andreas Madsen <amwebdk@gmail.com> Reviewed-By: Anna Henningsen <anna@addaleax.net> Reviewed-By: James M Snell <jasnell@gmail.com>
2017-10-19async_hooks: skip runtime checks when disabledAndreas Madsen
PR-URL: https://github.com/nodejs/node/pull/15454 Ref: https://github.com/nodejs/node/pull/14387 Ref: https://github.com/nodejs/node/pull/14722 Ref: https://github.com/nodejs/node/issues/14717 Ref: https://github.com/nodejs/node/issues/15448 Reviewed-By: Refael Ackermann <refack@gmail.com> Reviewed-By: Matteo Collina <matteo.collina@gmail.com> Reviewed-By: James M Snell <jasnell@gmail.com> Reviewed-By: Anna Henningsen <anna@addaleax.net>
2017-10-03async_hooks: fix reference in code commentBrian White
PR-URL: https://github.com/nodejs/node/pull/15748 Reviewed-By: Luigi Pinca <luigipinca@gmail.com> Reviewed-By: Colin Ihrig <cjihrig@gmail.com> Reviewed-By: Anna Henningsen <anna@addaleax.net> Reviewed-By: Andreas Madsen <amwebdk@gmail.com>
2017-09-26async_hooks: consistent internal namingAndreas Madsen
PR-URL: https://github.com/nodejs/node/pull/15569 Reviewed-By: Refael Ackermann <refack@gmail.com> Reviewed-By: Anna Henningsen <anna@addaleax.net> Reviewed-By: Ruben Bridgewater <ruben@bridgewater.de> Reviewed-By: James M Snell <jasnell@gmail.com>
2017-09-23async_hooks: support promise resolve hookAnna Henningsen
Add a `promiseResolve()` hook. PR-URL: https://github.com/nodejs/node/pull/15296 Reviewed-By: Trevor Norris <trev.norris@gmail.com> Reviewed-By: James M Snell <jasnell@gmail.com>
2017-09-15async_hooks,doc: some async_hooks improvementsJames M Snell
Update docs and type checking for AsyncResource type PR-URL: https://github.com/nodejs/node/pull/15103 Reviewed-By: Refael Ackermann <refack@gmail.com> Reviewed-By: Andreas Madsen <amwebdk@gmail.com> Reviewed-By: Ruben Bridgewater <ruben@bridgewater.de> Reviewed-By: Trevor Norris <trev.norris@gmail.com> Reviewed-By: Matteo Collina <matteo.collina@gmail.com>
2017-08-14async_hooks: don't abort unnecessarilyTrevor Norris
* id values of -1 are allowed. They indicate that the id was never correctly assigned to the async resource. These will appear in any call graph, and will only be apparent to those using the async_hooks module, then reported in an issue. * ids < -1 are still not allowed and will cause the application to exit the process; because there is no scenario where this should ever happen. * Add asyncId range checks to emitAfterScript(). * Fix emitBeforeScript() range checks which should have been || not &&. * Replace errors with entries in internal/errors. * Fix async_hooks tests that check for exceptions to match new internal/errors entries. NOTE: emit{Before,After,Destroy}() must continue to exit the process because in the case of an exception during hook execution the state of the application is unknowable. For example, an exception could cause a memory leak: const id_map = new Map(); before(id) { id_map.set(id, /* data object or similar */); }, after(id) { throw new Error('id never dies!'); id_map.delete(id); } Allowing a recoverable exception may also cause an abort because of a stack check in Environment::AsyncHooks::pop_ids() that verifies the async id and pop'd ids match. This case would be more difficult to debug than if fatalError() (lib/async_hooks.js) was called immediately. try { async_hooks.emitBefore(null, NaN); } catch (e) { } // do something async_hooks.emitAfter(5); It also allows an edge case where emitBefore() could be called twice and not have the pop_ids() CHECK fail: try { async_hooks.emitBefore(5, NaN); } catch (e) { } async_hooks.emitBefore(5); // do something async_hooks.emitAfter(5); There is the option of allowing mismatches in the stack and ignoring the check if no async hooks are enabled, but I don't believe going this far is necessary. PR-URL: https://github.com/nodejs/node/pull/14722 Reviewed-By: Anna Henningsen <anna@addaleax.net> Reviewed-By: Refael Ackermann <refack@gmail.com>
2017-08-14async_hooks: improve comments and function namesTrevor Norris
* Reword several of the comments to be more descriptive. * Rename functions to better indicate what they are doing. * Change AsyncHooks::uid_fields_ to be a fixed array instead of a pointer. * Define regex early so line ends before 80 columns. * Remove obsolete comments. * Rename AsyncHooks::InitScope::uid_fields_ to uid_fields_ptr_ because using the same name as AsyncHooks::uid_fields_ was confusing. * Place variables that are used to store the new set of hooks if another hook is enabled/disabled during hook execution into an object to act as a namespace. PR-URL: https://github.com/nodejs/node/pull/14722 Reviewed-By: Anna Henningsen <anna@addaleax.net> Reviewed-By: Refael Ackermann <refack@gmail.com>
2017-07-27async_hooks: remove deprecated APIsAnna Henningsen
These APIs were introduced during the lifetime of Node 8 in an experimental API and should safely be removable in Node 9+. PR-URL: https://github.com/nodejs/node/pull/14414 Reviewed-By: Refael Ackermann <refack@gmail.com> Reviewed-By: Andreas Madsen <amwebdk@gmail.com> Reviewed-By: Colin Ihrig <cjihrig@gmail.com> Reviewed-By: James M Snell <jasnell@gmail.com> Reviewed-By: Tobias Nießen <tniessen@tnie.de> Reviewed-By: Rich Trott <rtrott@gmail.com>
2017-07-25lib: modify destructuring for indentationRich Trott
ESLint 4.3.0 flags an extra indentation issue that affects two of our destructuring assignments in `lib`. This is a whitespace-only update to comply prior to updating. PR-URL: https://github.com/nodejs/node/pull/14417 Reviewed-By: James M Snell <jasnell@gmail.com> Reviewed-By: Colin Ihrig <cjihrig@gmail.com> Reviewed-By: Teddy Katz <teddy.katz@gmail.com> Reviewed-By: Roman Reiss <me@silverwind.io> Reviewed-By: Refael Ackermann <refack@gmail.com>
2017-07-13async_hooks: make AsyncResource match emitInitAndreas Madsen
AsyncResource previously called emitInitNative. Since AsyncResource is just an abstraction on top of the emitEventScript functions, it should call emitInitScript instead. PR-URL: https://github.com/nodejs/node/pull/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>
2017-07-13async_hooks: rename internal emit functionsAndreas Madsen
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: https://github.com/nodejs/node/pull/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>
2017-07-13async_hooks: fix nested hooks mutationAndreas Madsen
In some cases restoreTmpHooks is called too early, this causes active_hooks_array to change during execution of the init hooks. PR-URL: https://github.com/nodejs/node/pull/14143 Ref: https://github.com/nodejs/node/pull/14054#issuecomment-313915193 Reviewed-By: Refael Ackermann <refack@gmail.com> Reviewed-By: Trevor Norris <trev.norris@gmail.com> Reviewed-By: Anna Henningsen <anna@addaleax.net>
2017-07-13async_hooks: move restoreTmpHooks call to initRuben Bridgewater
This fixes an error that could occure by nesting async_hooks calls PR-URL: https://github.com/nodejs/node/pull/14054 Ref: https://github.com/nodejs/node/pull/13755#issuecomment-312616004 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: Andreas Madsen <amwebdk@gmail.com>
2017-07-07lib: remove excess indentationRich Trott
In anticipation of stricter linting for indentation, remove instances of extra indentation that will be flagged by the new rules. PR-URL: https://github.com/nodejs/node/pull/14090 Reviewed-By: Benjamin Gruenbaum <benjamingr@gmail.com> Reviewed-By: Tobias Nießen <tniessen@tnie.de> Reviewed-By: Luigi Pinca <luigipinca@gmail.com>
2017-07-06async_hooks: require parameter in emitBeforeAndreas Madsen
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-06async_hooks: use common emitBefore and emitAfterAndreas Madsen
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-05async_hooks: fix default nextTick triggerAsyncIdAndreas Madsen
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-05async_hooks: reduce duplication with factoryRuben Bridgewater
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-06-14async_hooks: rename currentId and triggerIdAndreas Madsen
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-06-10async_wrap: use kTotals to enable PromiseHookTrevor Norris
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-06-10Revert "async_hooks: only set up hooks if used"Trevor Norris
This reverts commit 410b1417648b5273fe80f4d910c6bbd198a00a2d. PR-URL: https://github.com/nodejs/node/pull/13509 Reviewed-By: Andreas Madsen <amwebdk@gmail.com> Reviewed-By: Anna Henningsen <anna@addaleax.net>
2017-06-08async_hooks: minor refactor to callback invocationAnna Henningsen
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-08async_hooks: make sure `.{en|dis}able() === this`Anna Henningsen
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-07test: increase coverage of async_hooksDavid Cai
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-05-26async_hooks: rename AsyncEvent to AsyncResourceAnna Henningsen
`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-25async_hooks: only set up hooks if usedAnna Henningsen
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-21async_hooks: add constructor check to async-hooksShadowbeetle
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-10lib: implement async_hooks API in coreTrevor Norris
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-10async_hooks: initial async_hooks implementationTrevor Norris
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>