Gerhard Stöbich
926162a2ea
async_hooks: enabledHooksExist shall return if hooks are enabled
...
Correct the implementaton of enabledHooksExist to return true if
there are enabled hooks.
Adapt callsites which used getHooksArrays() as workaround.
PR-URL: https://github.com/nodejs/node/pull/61054
Fixes: https://github.com/nodejs/node/issues/61019
Refs: https://github.com/nodejs/node/pull/59873
Reviewed-By: Matteo Collina <matteo.collina@gmail.com >
Reviewed-By: Gürgün Dayıoğlu <hey@gurgun.day >
2025-12-31 14:45:20 +00:00
James M Snell
308b6bc6de
async_hooks: move asyncResource property on bound function to EOL
...
PR-URL: https://github.com/nodejs/node/pull/58618
Reviewed-By: Michaël Zasso <targos@protonmail.com >
Reviewed-By: Chengzhong Wu <legendecas@gmail.com >
Reviewed-By: Matteo Collina <matteo.collina@gmail.com >
2025-06-09 15:20:30 +00:00
Joyee Cheung
e2bc395c42
inspector: skip promise hook in the inspector async hook
...
Instead of filtering out promises in the async hooks added
for async task tracking, add an internal path to skip adding
the promise hook completely for the inspector async hook.
The actual user-land promise tracking is already handled by
V8 inspector. This prevents the internal promise hook from
showing up and creating unnecessary noise when stepping into
async execution in the inspector.
PR-URL: https://github.com/nodejs/node/pull/57148
Refs: https://issues.chromium.org/issues/390581540
Reviewed-By: James M Snell <jasnell@gmail.com >
Reviewed-By: Yagiz Nizipli <yagiz@nizipli.com >
Reviewed-By: Chengzhong Wu <legendecas@gmail.com >
Reviewed-By: Geoffrey Booth <webadmin@geoffreybooth.com >
2025-02-23 01:07:21 +00:00
Aviv Keller
71785889c8
lib: prefer logical assignment
...
PR-URL: https://github.com/nodejs/node/pull/55044
Reviewed-By: James M Snell <jasnell@gmail.com >
Reviewed-By: Chemi Atlow <chemi@atlow.co.il >
Reviewed-By: Yagiz Nizipli <yagiz@nizipli.com >
Reviewed-By: Trivikram Kamat <trivikr.dev@gmail.com >
Reviewed-By: LiviaMedeiros <livia@cirno.name >
2024-10-09 06:42:16 +00:00
Stephen Belanger
7366808b85
lib: improve async_context_frame structure
...
PR-URL: https://github.com/nodejs/node/pull/54239
Reviewed-By: Gerhard Stöbich <deb2001-github@yahoo.de >
Reviewed-By: Chengzhong Wu <legendecas@gmail.com >
2024-08-09 19:44:42 +00:00
Stephen Belanger
d1229eeca4
lib: rewrite AsyncLocalStorage without async_hooks
...
PR-URL: https://github.com/nodejs/node/pull/48528
Reviewed-By: Matteo Collina <matteo.collina@gmail.com >
Reviewed-By: Yagiz Nizipli <yagiz@nizipli.com >
Reviewed-By: James M Snell <jasnell@gmail.com >
Reviewed-By: Benjamin Gruenbaum <benjamingr@gmail.com >
Reviewed-By: Rafael Gonzaga <rafael.nunu@hotmail.com >
Reviewed-By: Chengzhong Wu <legendecas@gmail.com >
Reviewed-By: Santiago Gimeno <santiago.gimeno@gmail.com >
Reviewed-By: Gerhard Stöbich <deb2001-github@yahoo.de >
2024-08-02 19:44:20 +00:00
Antoine du Hamel
a596af0819
tools: add lint rule to keep primordials in ASCII order
...
PR-URL: https://github.com/nodejs/node/pull/52592
Reviewed-By: Yagiz Nizipli <yagiz.nizipli@sentry.io >
Reviewed-By: Jacob Smith <jacob@frende.me >
Reviewed-By: Moshe Atlow <moshe@atlow.co.il >
2024-04-21 16:53:08 +00:00
Antoine du Hamel
9dbb1623ff
lib: add trailing commas to all public core modules
...
PR-URL: https://github.com/nodejs/node/pull/46848
Reviewed-By: Debadree Chatterjee <debadree333@gmail.com >
Reviewed-By: Moshe Atlow <moshe@atlow.co.il >
Reviewed-By: Anatoli Papirovski <apapirovski@mac.com >
Reviewed-By: Benjamin Gruenbaum <benjamingr@gmail.com >
Reviewed-By: Rafael Gonzaga <rafael.nunu@hotmail.com >
Reviewed-By: Jiawen Geng <technicalcute@gmail.com >
Reviewed-By: Trivikram Kamat <trivikr.dev@gmail.com >
Reviewed-By: Yongsheng Zhang <zyszys98@gmail.com >
2023-02-28 12:10:24 +01:00
flakey5
9a82938b82
lib: add AsyncLocalStorage.bind() and .snapshot()
...
PR-URL: https://github.com/nodejs/node/pull/46387
Reviewed-By: Stephen Belanger <admin@stephenbelanger.com >
Reviewed-By: Chengzhong Wu <legendecas@gmail.com >
Reviewed-By: Gerhard Stöbich <deb2001-github@yahoo.de >
2023-02-19 13:51:43 -08:00
James M Snell
9fafb0a090
async_hooks: deprecate the AsyncResource.bind asyncResource property
...
Runtime-deprecates the `asyncResource` property that is attached to
the wrapper function returned by `asyncResource.bind()`. This property
is not expected to align with the equivalent `asyncContext.wrap()`
API in the proposed TC39 standard.
PR-URL: https://github.com/nodejs/node/pull/46432
Reviewed-By: Chengzhong Wu <legendecas@gmail.com >
Reviewed-By: Stephen Belanger <admin@stephenbelanger.com >
Reviewed-By: Gerhard Stöbich <deb2001-github@yahoo.de >
Reviewed-By: Michaël Zasso <targos@protonmail.com >
Reviewed-By: Matteo Collina <matteo.collina@gmail.com >
2023-02-03 02:02:19 +00:00
James M Snell
dc90810f9f
async_hooks: remove experimental onPropagate option
...
The `onPropagate` option for `AsyncLocalStorage` is problematic for a
couple of reasons:
1. It is not expected to be forwards compatible in any way with the
upcoming TC-39 `AsyncContext` proposal.
2. It introduces a non-trivial O(n) cost invoking a JavaScript callback
for *every* AsyncResource that is created, including every Promise.
While it is still experimental, I recommend removing it while we can
revisit the fundamental use cases in light of the coming `AsyncContext`
proposal.
Refs: https://github.com/nodejs/node/issues/46374
PR-URL: https://github.com/nodejs/node/pull/46386
Reviewed-By: Stephen Belanger <admin@stephenbelanger.com >
Reviewed-By: Vladimir de Turckheim <vlad2t@hotmail.com >
Reviewed-By: Geoffrey Booth <webadmin@geoffreybooth.com >
Reviewed-By: Benjamin Gruenbaum <benjamingr@gmail.com >
Reviewed-By: Gerhard Stöbich <deb2001-github@yahoo.de >
Reviewed-By: Chengzhong Wu <legendecas@gmail.com >
2023-02-01 07:37:05 -08:00
Deokjin Kim
be93b7a582
lib: refactor to use validate function
...
Throwing error after checking type is repeated. So replace
it with validate function.
PR-URL: https://github.com/nodejs/node/pull/46101
Reviewed-By: Matteo Collina <matteo.collina@gmail.com >
Reviewed-By: Luigi Pinca <luigipinca@gmail.com >
Reviewed-By: Minwoo Jung <nodecorelab@gmail.com >
2023-01-14 09:52:26 +00:00
Deokjin Kim
2582a0d2dd
async_hooks: refactor to use validateObject
...
PR-URL: https://github.com/nodejs/node/pull/46004
Reviewed-By: Antoine du Hamel <duhamelantoine1995@gmail.com >
Reviewed-By: Colin Ihrig <cjihrig@gmail.com >
Reviewed-By: Luigi Pinca <luigipinca@gmail.com >
2023-01-01 10:50:33 +00:00
Gerhard Stöbich
67d1831e9b
async_hooks: add hook to stop propagation
...
Add hook to AsyncLocalStorage to allow user to stop propagation.
This is needed to avoid leaking a store if e.g. the store indicates
that its operations are finished or it reached its time to live.
PR-URL: https://github.com/nodejs/node/pull/45386
Reviewed-By: Stephen Belanger <admin@stephenbelanger.com >
Reviewed-By: Minwoo Jung <nodecorelab@gmail.com >
Reviewed-By: Chengzhong Wu <legendecas@gmail.com >
2022-11-15 12:27:03 +00:00
LiviaMedeiros
dc2a5d79c2
async_hooks: use kEmptyObject
...
PR-URL: https://github.com/nodejs/node/pull/43159
Reviewed-By: Matteo Collina <matteo.collina@gmail.com >
Reviewed-By: Antoine du Hamel <duhamelantoine1995@gmail.com >
2022-06-11 12:18:11 +02:00
Antoine du Hamel
06d8606960
lib: use null-prototype objects for property descriptors
...
Refs: https://github.com/nodejs/node/pull/42921
PR-URL: https://github.com/nodejs/node/pull/43270
Reviewed-By: Paolo Insogna <paolo@cowtech.it >
Reviewed-By: Matteo Collina <matteo.collina@gmail.com >
Reviewed-By: Chengzhong Wu <legendecas@gmail.com >
Reviewed-By: Minwoo Jung <nodecorelab@gmail.com >
2022-06-03 09:23:58 +01:00
Roch Devost
409c594887
lib: fix AsyncResource.bind not using 'this' from the caller by default
...
PR-URL: https://github.com/nodejs/node/pull/42177
Reviewed-By: Antoine du Hamel <duhamelantoine1995@gmail.com >
Reviewed-By: Gerhard Stöbich <deb2001-github@yahoo.de >
Reviewed-By: Bradley Farias <bradley.meck@gmail.com >
Reviewed-By: Bryan English <bryan@bryanenglish.com >
Reviewed-By: James M Snell <jasnell@gmail.com >
2022-03-08 22:00:55 +00:00
Rafael Gonzaga
d10085bcb1
async_hooks: expose async_wrap providers
...
docs: add asyncWrapProviders api doc
tests(async_hooks): use internalBinding for comparisson
fix(test-async-wrap): lint error
docs: use REPLACEME for asyncWrapProviders
update: use freeze and copy for asyncWrapProviders
update(async_hooks): use primordials on asyncWrapProviders
fix: use common to expect error
docs(asyncWrapProviders): rephrase return type
fix: lint md
fix: lint md
docs(async_hooks): typo
Co-authored-by: Stephen Belanger <admin@stephenbelanger.com >
update(asyncWrapProviders): add __proto__ as null
Co-authored-by: Simone Busoli <simone.busoli@gmail.com >
Co-authored-by: Michaël Zasso <targos@protonmail.com >
test: adjust __proto__ assertion
docs: add DEP0111 link
PR-URL: https://github.com/nodejs/node/pull/40760
Reviewed-By: Matteo Collina <matteo.collina@gmail.com >
Reviewed-By: Gerhard Stöbich <deb2001-github@yahoo.de >
Reviewed-By: Stephen Belanger <admin@stephenbelanger.com >
2021-11-12 21:48:34 +00:00
Stephen Belanger
926152a38c
async_hooks: use resource stack for AsyncLocalStorage run
...
PR-URL: https://github.com/nodejs/node/pull/39890
Reviewed-By: James M Snell <jasnell@gmail.com >
Reviewed-By: Vladimir de Turckheim <vlad2t@hotmail.com >
Reviewed-By: Gerhard Stöbich <deb2001-github@yahoo.de >
Reviewed-By: Minwoo Jung <nodecorelab@gmail.com >
Reviewed-By: Zijian Liu <lxxyxzj@gmail.com >
2021-08-31 17:04:35 +00:00
Antoine du Hamel
f8853dd8cc
async_hooks: refactor to avoid unsafe array iteration
...
PR-URL: https://github.com/nodejs/node/pull/37125
Reviewed-By: Zijian Liu <lxxyxzj@gmail.com >
Reviewed-By: Darshan Sen <raisinten@gmail.com >
2021-02-01 16:16:38 +01:00
ZiJian Liu
064a7070c7
lib: refactor to use validateFunction
...
add validateFunction and refactor to use validateFunction
PR-URL: https://github.com/nodejs/node/pull/37045
Reviewed-By: Antoine du Hamel <duhamelantoine1995@gmail.com >
Reviewed-By: Darshan Sen <raisinten@gmail.com >
Reviewed-By: Rich Trott <rtrott@gmail.com >
Reviewed-By: Luigi Pinca <luigipinca@gmail.com >
Reviewed-By: James M Snell <jasnell@gmail.com >
2021-01-27 20:46:54 +02:00
James M Snell
324a6c235a
async_hooks: add thisArg to AsyncResource.bind
...
Semver-major
Support setting the `thisArg` for AsyncResource.bind and
AsyncResource.prototype.bind. If `thisArg` is not set,
then `this` will be set to the `AsyncResource` instance.
Fixes: https://github.com/nodejs/node/issues/36051
Signed-off-by: James M Snell <jasnell@gmail.com >
PR-URL: https://github.com/nodejs/node/pull/36782
Reviewed-By: Juan José Arboleda <soyjuanarbol@gmail.com >
Reviewed-By: Matteo Collina <matteo.collina@gmail.com >
Reviewed-By: Michaël Zasso <targos@protonmail.com >
Reviewed-By: Gerhard Stöbich <deb2001-github@yahoo.de >
2021-01-09 11:22:35 -08:00
Antoine du Hamel
f47d65538a
async_hooks: refactor to use more primordials
...
PR-URL: https://github.com/nodejs/node/pull/36168
Reviewed-By: Rich Trott <rtrott@gmail.com >
Reviewed-By: James M Snell <jasnell@gmail.com >
Reviewed-By: Benjamin Gruenbaum <benjamingr@gmail.com >
Reviewed-By: Trivikram Kamat <trivikr.dev@gmail.com >
2020-11-20 20:10:19 +00:00
Stephen Belanger
06f0d78eb9
async_hooks: fix leak in AsyncLocalStorage exit
...
If exit is called and then run or enterWith are called within the
exit function, the als instace should not be added to the storageList
additional times. The correct behaviour is to remove the instance
from the storageList before executing the exit handler and then to
restore it after.
PR-URL: https://github.com/nodejs/node/pull/35779
Reviewed-By: Vladimir de Turckheim <vlad2t@hotmail.com >
Reviewed-By: Michael Dawson <midawson@redhat.com >
Reviewed-By: Gerhard Stöbich <deb2001-github@yahoo.de >
Reviewed-By: Andrey Pechkurov <apechkurov@gmail.com >
Reviewed-By: Rich Trott <rtrott@gmail.com >
2020-11-11 11:32:50 +00:00
Gerhard Stoebich
014feecc44
async_hooks: avoid GC tracking of AsyncResource in ALS
...
Manually destroy the AsyncResource created by AsyncLocalStore.run() to
avoid unneeded GC tracking in case a destroy hooks is present.
PR-URL: https://github.com/nodejs/node/pull/34653
Reviewed-By: Anna Henningsen <anna@addaleax.net >
Reviewed-By: James M Snell <jasnell@gmail.com >
2020-08-07 08:51:19 -07:00
Gerhard Stoebich
a4e1755df2
async_hooks: don't read resource if ALS is disabled
...
Only call executionAsyncResource() in getStore() if the ALS instance is
enabled because the resource is not needed otherwise.
PR-URL: https://github.com/nodejs/node/pull/34617
Reviewed-By: Anna Henningsen <anna@addaleax.net >
Reviewed-By: Michaël Zasso <targos@protonmail.com >
Reviewed-By: James M Snell <jasnell@gmail.com >
Reviewed-By: Luigi Pinca <luigipinca@gmail.com >
2020-08-06 23:31:16 +02:00
Gerhard Stoebich
48249889b6
async_hooks: avoid unneeded AsyncResource creation
...
Inspired by the callstack at https://github.com/nodejs/node/issues/34556#issuecomment-666743528
If the wanted store is equal to the active store it's not needed to
create an AsyncResource.
Refs: https://github.com/nodejs/node/issues/34556#issuecomment-666743528
PR-URL: https://github.com/nodejs/node/pull/34616
Reviewed-By: Anna Henningsen <anna@addaleax.net >
Reviewed-By: Stephen Belanger <admin@stephenbelanger.com >
Reviewed-By: Vladimir de Turckheim <vlad2t@hotmail.com >
Reviewed-By: Andrey Pechkurov <apechkurov@gmail.com >
2020-08-06 23:26:13 +02:00
Gerhard Stoebich
3ea94ec845
async_hooks: improve property descriptors in als.bind
...
The length property should be non enumerable to match behavior of
normal functions.
The asyncResource property is enumerable and therefore it should be
also writable to avoid issues like there:
https://github.com/nodejs/node/pull/30932#discussion_r379679982
Both properties should be configurable.
Refs: https://github.com/nodejs/node/pull/34574
PR-URL: https://github.com/nodejs/node/pull/34620
Reviewed-By: Andrey Pechkurov <apechkurov@gmail.com >
Reviewed-By: Anna Henningsen <anna@addaleax.net >
Reviewed-By: James M Snell <jasnell@gmail.com >
2020-08-04 18:05:01 +02:00
James M Snell
74df7496ff
async_hooks: add AsyncResource.bind utility
...
Creates an internal AsyncResource and binds a function to it,
ensuring that the function is invoked within execution context
in which bind was called.
PR-URL: https://github.com/nodejs/node/pull/34574
Reviewed-By: Stephen Belanger <admin@stephenbelanger.com >
Reviewed-By: Gus Caplan <me@gus.host >
Reviewed-By: Matteo Collina <matteo.collina@gmail.com >
Reviewed-By: Andrey Pechkurov <apechkurov@gmail.com >
Reviewed-By: Gerhard Stöbich <deb2001-github@yahoo.de >
2020-08-03 18:40:16 -07:00
Stephen Belanger
13c5a1629c
async_hooks: move PromiseHook handler to JS
...
This avoids the need to wrap every promise in an AsyncWrap and also
makes it easier to skip the machinery to track destroy events when
there's no destroy listener.
Co-authored-by: Andrey Pechkurov <apechkurov@gmail.com >
PR-URL: https://github.com/nodejs/node/pull/32891
Reviewed-By: Matteo Collina <matteo.collina@gmail.com >
Reviewed-By: Andrey Pechkurov <apechkurov@gmail.com >
Reviewed-By: Anna Henningsen <anna@addaleax.net >
Reviewed-By: Gerhard Stöbich <deb2001-github@yahoo.de >
Reviewed-By: Chengzhong Wu <legendecas@gmail.com >
2020-05-09 07:52:22 +02:00
Andrey Pechkurov
50dd63e8ef
async_hooks: merge run and exit methods
...
PR-URL: https://github.com/nodejs/node/pull/31950
Reviewed-By: Vladimir de Turckheim <vlad2t@hotmail.com >
Reviewed-By: Gerhard Stöbich <deb2001-github@yahoo.de >
2020-04-13 18:37:44 +02:00
Stephen Belanger
f7f0441997
async_hooks: prevent sync methods of async storage exiting outer context
...
PR-URL: https://github.com/nodejs/node/pull/31950
Reviewed-By: Vladimir de Turckheim <vlad2t@hotmail.com >
Reviewed-By: Gerhard Stöbich <deb2001-github@yahoo.de >
2020-04-13 18:37:09 +02:00
Andrey Pechkurov
561dda273f
async_hooks: move to lazy destroy hook registration in AsyncResource
...
PR-URL: https://github.com/nodejs/node/pull/32429
Reviewed-By: Gerhard Stöbich <deb2001-github@yahoo.de >
Reviewed-By: Vladimir de Turckheim <vlad2t@hotmail.com >
2020-04-06 16:14:43 +02:00
Stephen Belanger
d368dcc63a
async_hooks: add sync enterWith to ALS
...
This allows transitioning the entire following sync and async execution
sub-tree to the given async storage context. With this one can be sure
the context binding will remain for any following sync activity and all
descending async execution whereas the `run*(...)` methods must wrap
everything that is intended to exist within the context. This is helpful
for scenarios such as prepending a `'connection'` event to an http
server which binds everything that occurs within each request to
the given context. This is helpful for APMs to minimize the need
for patching and especially adding closures.
PR-URL: https://github.com/nodejs/node/pull/31945
Reviewed-By: Vladimir de Turckheim <vlad2t@hotmail.com >
Reviewed-By: Matteo Collina <matteo.collina@gmail.com >
Reviewed-By: Michael Dawson <michael_dawson@ca.ibm.com >
2020-03-09 14:24:21 -04:00
Andrey Pechkurov
86ab4ee6e4
async_hooks: fix ctx loss after nested ALS calls
...
PR-URL: https://github.com/nodejs/node/pull/32085
Reviewed-By: Stephen Belanger <admin@stephenbelanger.com >
Reviewed-By: Vladimir de Turckheim <vlad2t@hotmail.com >
Reviewed-By: Michael Dawson <michael_dawson@ca.ibm.com >
2020-03-06 14:07:07 -05:00
Andrey Pechkurov
6510a741c4
async_hooks: add store arg in AsyncLocalStorage
...
This commit introduces store as the first argument in
AsyncLocalStorage's run methods. The change is motivated by the
following expectation: most users are going to use a custom object
as the store and an extra Map created by the previous implementation
is an overhead for their use case.
Important note. This is a backwards incompatible change.
It was discussed and agreed an incompatible change is ok
since the API is still experimental and the modified
methods were only added within the last week so usage
will be minimal to none.
PR-URL: https://github.com/nodejs/node/pull/31930
Reviewed-By: Stephen Belanger <admin@stephenbelanger.com >
Reviewed-By: Vladimir de Turckheim <vlad2t@hotmail.com >
Reviewed-By: Matteo Collina <matteo.collina@gmail.com >
Reviewed-By: Michaël Zasso <targos@protonmail.com >
Reviewed-By: Michael Dawson <michael_dawson@ca.ibm.com >
2020-02-27 15:00:23 -05:00
vdeturckheim
9c702922cd
async_hooks: introduce async-context API
...
Adding AsyncLocalStorage class to async_hooks
module.
This API provide a simple CLS-like set
of features.
Co-authored-by: Andrey Pechkurov <apechkurov@gmail.com >
PR-URL: https://github.com/nodejs/node/pull/26540
Reviewed-By: Matteo Collina <matteo.collina@gmail.com >
Reviewed-By: Stephen Belanger <admin@stephenbelanger.com >
Reviewed-By: Gireesh Punathil <gpunathi@in.ibm.com >
Reviewed-By: James M Snell <jasnell@gmail.com >
Reviewed-By: Michaël Zasso <targos@protonmail.com >
2020-02-23 20:24:02 +01:00
legendecas
75311dbc2f
async_hooks: ensure event after been emitted on runInAsyncScope
...
The exception handler user-defined will not automatically emit after
for the async resource.
Also removes a duplicated case
`test-emit-after-uncaught-exception-runInAsyncScope.js`
which is identical to test-emit-after-uncaught-exception.js.
Refs: https://github.com/nodejs/node/pull/30965
PR-URL: https://github.com/nodejs/node/pull/31784
Fixes: https://github.com/nodejs/node/issues/31783
Reviewed-By: Vladimir de Turckheim <vlad2t@hotmail.com >
Reviewed-By: James M Snell <jasnell@gmail.com >
Reviewed-By: Anna Henningsen <anna@addaleax.net >
2020-02-14 16:55:02 +01:00
Matteo Collina
9fdb6e6aaf
async_hooks: add executionAsyncResource
...
Remove the need for the destroy hook in the basic APM case.
Co-authored-by: Stephen Belanger <admin@stephenbelanger.com >
PR-URL: https://github.com/nodejs/node/pull/30959
Reviewed-By: Matteo Collina <matteo.collina@gmail.com >
Reviewed-By: Anna Henningsen <anna@addaleax.net >
Reviewed-By: Vladimir de Turckheim <vlad2t@hotmail.com >
Reviewed-By: Chengzhong Wu <legendecas@gmail.com >
Reviewed-By: James M Snell <jasnell@gmail.com >
2020-02-11 20:59:09 +01:00
Anatoli Papirovski
4de31d517f
async_hooks: remove internal only error checking
...
This error checking is mostly unnecessary and is just a Node core
developer nicety, rather than something that is needed for the
user-land. It can be safely removed without any practical
impact while making nextTick, timers, immediates and AsyncResource
substantially faster.
PR-URL: https://github.com/nodejs/node/pull/30967
Reviewed-By: James M Snell <jasnell@gmail.com >
Reviewed-By: Stephen Belanger <admin@stephenbelanger.com >
Reviewed-By: Rich Trott <rtrott@gmail.com >
Reviewed-By: Ruben Bridgewater <ruben@bridgewater.de >
2020-01-11 19:20:45 -08:00
Anatoli Papirovski
503900b463
async_hooks: ensure proper handling in runInAsyncScope
...
We should never try to manually run emitAfter in case of an error,
the exception handler will do it for us, if we're going to recover.
PR-URL: https://github.com/nodejs/node/pull/30965
Reviewed-By: Anna Henningsen <anna@addaleax.net >
Reviewed-By: Rich Trott <rtrott@gmail.com >
Reviewed-By: Ruben Bridgewater <ruben@bridgewater.de >
Reviewed-By: James M Snell <jasnell@gmail.com >
2019-12-16 21:59:50 -08:00
Sebastien Ahkrin
eac3f0adc4
lib: replace Symbol global by the primordials Symbol
...
PR-URL: https://github.com/nodejs/node/pull/30737
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: Ruben Bridgewater <ruben@bridgewater.de >
Reviewed-By: Luigi Pinca <luigipinca@gmail.com >
2019-12-08 13:38:58 +01:00
Michaël Zasso
1f9a5ae7aa
lib: use static Number properties from primordials
...
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-30 13:45:38 +01:00
Michaël Zasso
0646eda4fc
lib: flatten access to primordials
...
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-11-25 10:28:15 +01:00
Anna Henningsen
6858c7e3e7
async_hooks: only emit after for AsyncResource if stack not empty
...
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-10-26 15:19:23 +02:00
Anatoli Papirovski
cde3928a10
process: improve queueMicrotask performance
...
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-06-10 07:49:40 +02:00
Anatoli Papirovski
d3d4e10107
async_hooks: improve AsyncResource performance
...
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-05 05:37:01 +02:00
Michaël Zasso
0817840f77
lib: force using primordials for JSON, Math and Reflect
...
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-04-03 21:36:08 +08:00
Matteo Collina
9d064439e5
async_hooks: remove deprecated emitBefore and emitAfter
...
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 >
2019-03-18 11:36:48 +01:00
Ruben Bridgewater
50dd555910
doc,lib,test: capitalize comment sentences
...
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-12-17 17:14:35 +01:00