profile
viewpoint
Michaël Zasso targos Zakodium Sàrl Switzerland

mcollina/make-promises-safe 425

A node.js module to make the use of promises safe

Slynova-Org/flydrive 160

☁️ Flexible and Fluent framework-agnostic driver based system to manage storage in Node.js

ES-Community/nsecure 35

Node.js security CLI / API that allow you to deeply analyze the dependency tree of a given package / directory

mcollina/stream-iterators-utils 29

Utility belt for using async iterators with streams

NPellet/jsGraph 23

Dynamic graphing library

nodejs/v8 17

The official mirror of the V8 git repository

ES-Community/ndbg 6

Node.js CLI debugging tools

ES-Community/ex-luminous 3

Ex-luminous Game - Created for Ludum Dare 45

pull request commentnodejs/node-v8

tools: update v8 gypfiles

It's in now (there's a daily automatic update of this repo)

gengjiawen

comment created time in 17 hours

issue closedcheminfo/is-any-array

Export default ?

I'm migrating this project to es6 module but I wonder if I should export default or just export.

If I export as default it means that I would need to use the syntax const isAnyArray = require('is-any-array').default; and add the 'default' at the end ?

This does not look very nice and I would then prefer const {isAnyArray} = require('is-any-array');

https://github.com/cheminfo/is-any-array/blob/aad26d45faec79966dc49f7221e3b8e331d64fa0/src/index.js#L3-L5

@targos I guess it is not the first time I ask you this question ...

closed time in a day

lpatiny

PR closed nodejs/node-v8

Reviewers
tools: update v8 gypfiles

Fix #139

Thanks @seishun for point out the problem.

Checklist

<!-- Remove items that do not apply. For completed items, change [ ] to [x]. -->

  • [ ] make -j4 test (UNIX), or vcbuild test (Windows) passes
  • [ ] tests and/or benchmarks are included
  • [ ] documentation is changed or added
  • [ ] commit message follows commit guidelines
+4 -0

2 comments

1 changed file

gengjiawen

pr closed time in a day

pull request commentnodejs/node-v8

tools: update v8 gypfiles

Thanks! Landed in https://github.com/nodejs/node/commit/50dd660fa88ff24217e77d57d94f4cee87e964f5

gengjiawen

comment created time in a day

push eventnodejs/node

gengjiawen

commit sha 50dd660fa88ff24217e77d57d94f4cee87e964f5

tools: update v8 gypfiles

view details

push time in a day

issue commentcheminfo/is-any-array

Export default ?

If you build with rollup and export as default, you will be able to require('is-any-array'). The question to ask is: will the library always have only a default export and no other? If the answer is yes, you can export as default. If it's no, or you're not sure, use a named export.

lpatiny

comment created time in a day

issue commentnodejs/TSC

Ability for website team to transfer issues to nodejs/help

Collaborators already have write access to the help repo. I'm +1 on adding the website team.

nschonni

comment created time in 2 days

Pull request review commentnodejs/node

crypto: simplify exportKeyingMaterial

 void SSLWrap<Base>::ExportKeyingMaterial(    AllocatedBuffer out = env->AllocateManaged(olen); -  ByteSource key;--  int useContext = 0;-  if (!args[2]->IsNull() && Buffer::HasInstance(args[2])) {-    key = ByteSource::FromBuffer(args[2]);--    useContext = 1;-  }+  ByteSource context;+  bool use_context = !args[2]->IsUndefined();+  if (use_context)+    context = ByteSource::FromBuffer(args[2]);    if (SSL_export_keying_material(w->ssl_.get(),                                  reinterpret_cast<unsigned char*>(out.data()),                                  olen,                                  *label,                                  label.length(),                                  reinterpret_cast<const unsigned char*>(-                                   key.get()),-                                 key.size(),-                                 useContext) != 1) {+                                   context.get()),

@tniessen in case you don't know: make format-cpp before git commit should take care of style issues

tniessen

comment created time in 2 days

created tagcheminfo/chromatography

tagv4.0.0-0

Tools for storing, search and analyze GC/MS spectra

created time in 2 days

push eventcheminfo/chromatography

Michaël Zasso

commit sha eb1ccf20ab873a5633f973a0a9bebf5b94ddf6b0

4.0.0-0

view details

push time in 2 days

push eventcheminfo/chromatography

Michaël Zasso

commit sha 629ff875bdb79be0a5bb744e4a2907ed8e488fc7

refactor: rename serie to series Also remove circular dependency

view details

Michaël Zasso

commit sha 2603cd97d7ddd483379b6b19b2795a3501f645f9

refactor: normalize project and add TS documentation.

view details

push time in 2 days

pull request commentnodejs/node

async_hooks: introduce mandatory store argument in AsyncLocalStorage run methods

@nodejs/tsc this is a breaking change but for something that has not been shipped in any release yet. I don't think we have anything in the processes for this case. Do we need an extra step to land this?

I added backport-blocked label to https://github.com/nodejs/node/pull/26540 so it doesn't land in a release before this change. In general, breaking changes to experimental features can land in any release, as long as we document them.

puzpuzpuz

comment created time in 2 days

pull request commentnodejs/node

async-hooks: introduce async-storage API

Should wait for https://github.com/nodejs/node/pull/31930 before this is backported to v13.x

vdeturckheim

comment created time in 2 days

push eventcheminfo/chromatography

Michaël Zasso

commit sha 733f875c1823969e3ca03f4658513d087e73a951

chore: update dependencies

view details

push time in 3 days

created tagcheminfo/tools

tagcheminfo-build@1.0.7

CLI tools to help cheminfo developers

created time in 3 days

push eventcheminfo/tools

Michaël Zasso

commit sha bbbfe1b55676bb7a3c683523e88f24a0dd86e75f

Publish - cheminfo-build@1.0.7

view details

push time in 3 days

push eventcheminfo/tools

Michaël Zasso

commit sha 9743ffd4430a14354db9a8104a9c1104006ddf76

chore: update dependencies Replace deprecated rollup plugins

view details

push time in 3 days

fork targos/node-gyp

Node.js native addon build tool

fork in 3 days

push eventcheminfo/chromatography

Michaël Zasso

commit sha fd044acd0c88438b46a61e1d43df26eae2b391da

chore: update spectrum-generator

view details

push time in 3 days

push eventcheminfo/spectrum-generator

Michaël Zasso

commit sha 368f3a96de7a5903c3d1de5043666e8e8e9ec7ca

chore: fix build

view details

push time in 3 days

push eventcheminfo/spectrum-generator

Michaël Zasso

commit sha f242086a27ce5ce26a945a6f469896f0100c71d8

doc: fix readme links

view details

push time in 3 days

push eventcheminfo/spectrum-generator

Michaël Zasso

commit sha b5289560c2c25020be12e7fd291a9b5da73bbd76

chore: update dependenciesUse xsadd instead of seedrandom

view details

push time in 3 days

created tagcheminfo/tools

tagcheminfo-publish@1.0.9

CLI tools to help cheminfo developers

created time in 3 days

push eventcheminfo/tools

Michaël Zasso

commit sha 16e307c81cc298ca79fdf4254f1e5524116c92ef

chore: update dependencies

view details

Michaël Zasso

commit sha a7eb4832677156b883902278599c4324b91b8c98

Publish - cheminfo-build@1.0.6 - cheminfo-publish@1.0.9

view details

push time in 3 days

created tagcheminfo/tools

tagcheminfo-build@1.0.6

CLI tools to help cheminfo developers

created time in 3 days

push eventcheminfo/chromatography

Michaël Zasso

commit sha f193eb93b801203d99a7c5e22d6ddac8409df152

fix: remove unneeded dependencies

view details

Michaël Zasso

commit sha 1c3ab22bf0e47e9ace61ff3ee7ab65e4f9652786

chore: fix rollup warning

view details

push time in 3 days

push eventcheminfo/chromatography

Michaël Zasso

commit sha 4189ecc4cefa9627c7670c505f96d032700d00ba

fix: do not depend on mf-global

view details

push time in 3 days

push eventcheminfo/chromatography

Michaël Zasso

commit sha 792540296a5329d1edd9abc392eef5419ebb1cdd

chore: update dependencies

view details

push time in 3 days

issue commentnodejs/node-v8

Failing test: test-inspector-multisession-ws

@mmarchini thanks a lot for looking into this!

targos

comment created time in 3 days

issue commentcheminfo/openchemlib-js

[feature request] providing a getBondByAtomID api to get the bond between two adjacent atoms

Isn't the getBond method what you're looking for?

kuige

comment created time in 4 days

PR opened ryzokuken/gyp

Sync code base with nodejs/node
+1357 -391

0 comment

52 changed files

pr created time in 5 days

create barnchtargos/gyp-1

branch : sync

created branch time in 5 days

fork targos/gyp-1

The gyp build system

fork in 5 days

delete branch targos/node

delete branch : sync-gyp

delete time in 6 days

PR closed nodejs/node

tools: sync gyp code base with node-gyp repo build tools

This syncs the gyp code base so that it is identical to the one in nodejs/node-gyp.

This was done by removing the code in nodejs/node-gyp, copying from nodejs/node and then manually reviewing and adapting the diff.

+1354 -821

13 comments

28 changed files

targos

pr closed time in 6 days

pull request commentnodejs/node

tools: sync gyp code base with node-gyp repo

Landed in cf0096104752

targos

comment created time in 6 days

push eventnodejs/node

Michaël Zasso

commit sha cf0096104752607c7374a7f7297139e60b03c59d

tools: sync gyp code base with node-gyp repo PR-URL: https://github.com/nodejs/node/pull/30563 Reviewed-By: Ujjwal Sharma <ryzokuken@disroot.org> Reviewed-By: Christian Clauss <cclauss@me.com> Reviewed-By: Ruben Bridgewater <ruben@bridgewater.de> Reviewed-By: Rich Trott <rtrott@gmail.com>

view details

push time in 6 days

push eventtargos/node

Matteo Collina

commit sha 9fdb6e6aaf45b2364bac89a8f240772f49503ee6

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>

view details

Rich Trott

commit sha 3eba33eb07353b8b642792d928425b4c4977767e

util: throw if unreachable code is reached If a comparison code path that is supposed to be unreachable is reached, throw. Add a c8 comment to ignore coverage for the line, as it should be unreachable. PR-URL: https://github.com/nodejs/node/pull/31712 Reviewed-By: Gus Caplan <me@gus.host> Reviewed-By: Anto Aravinth <anto.aravinth.cse@gmail.com> Reviewed-By: Yosuke Furukawa <yosuke.furukawa@gmail.com> Reviewed-By: Yongsheng Zhang <zyszys98@gmail.com> Reviewed-By: James M Snell <jasnell@gmail.com> Reviewed-By: Ruben Bridgewater <ruben@bridgewater.de> Reviewed-By: Colin Ihrig <cjihrig@gmail.com>

view details

Rich Trott

commit sha b3548d0c3bc636653a883b2085ac57b43924c555

doc: reword section title in addons.md Throughout the docs, we sometimes write the possessive of _Node.js_ as _Node.js'_ and other times as _Node.js's_. The former conforms with some generally accepted style guides (e.g., Associated Press Stylebook) while the latter complies with others (e.g., Chicago Manual of Style). Since there is no clear authoritative answer as to which form is correct, and since (at least to me) both are visually jarring and sometimes cause a pause to understand, I'd like to reword things to eliminate the possessive form where possible. This is one of those examples. PR-URL: https://github.com/nodejs/node/pull/31713 Reviewed-By: Ben Noordhuis <info@bnoordhuis.nl> Reviewed-By: Beth Griggs <Bethany.Griggs@uk.ibm.com> Reviewed-By: James M Snell <jasnell@gmail.com> Reviewed-By: Tobias Nießen <tniessen@tnie.de> Reviewed-By: Colin Ihrig <cjihrig@gmail.com> Reviewed-By: Anna Henningsen <anna@addaleax.net> Reviewed-By: Ruben Bridgewater <ruben@bridgewater.de>

view details

Rich Trott

commit sha b5f2448bc9f790fb5f4a3ee8ebfbe7bb9a6ae8a4

doc: reword possessive form of Node.js in repl.md Throughout the docs, we sometimes write the possessive of _Node.js_ as _Node.js'_ and other times as _Node.js's_. The former conforms with some generally accepted style guides (e.g., Associated Press Stylebook) while the latter complies with others (e.g., Chicago Manual of Style). Since there is no clear authoritative answer as to which form is correct, and since (at least to me) both are visually jarring and sometimes cause a pause to understand, I'd like to reword things to eliminate the possessive form where possible. This is one of those examples. PR-URL: https://github.com/nodejs/node/pull/31713 Reviewed-By: Ben Noordhuis <info@bnoordhuis.nl> Reviewed-By: Beth Griggs <Bethany.Griggs@uk.ibm.com> Reviewed-By: James M Snell <jasnell@gmail.com> Reviewed-By: Tobias Nießen <tniessen@tnie.de> Reviewed-By: Colin Ihrig <cjihrig@gmail.com> Reviewed-By: Anna Henningsen <anna@addaleax.net> Reviewed-By: Ruben Bridgewater <ruben@bridgewater.de>

view details

Rich Trott

commit sha e81f60c8d338722b3d0b4d7ccda9b6db9f864e29

doc: reword possessive form of Node.js in modules.md Throughout the docs, we sometimes write the possessive of _Node.js_ as _Node.js'_ and other times as _Node.js's_. The former conforms with some generally accepted style guides (e.g., Associated Press Stylebook) while the latter complies with others (e.g., Chicago Manual of Style). Since there is no clear authoritative answer as to which form is correct, and since (at least to me) both are visually jarring and sometimes cause a pause to understand, I'd like to reword things to eliminate the possessive form where possible. This is one of those examples. PR-URL: https://github.com/nodejs/node/pull/31713 Reviewed-By: Ben Noordhuis <info@bnoordhuis.nl> Reviewed-By: Beth Griggs <Bethany.Griggs@uk.ibm.com> Reviewed-By: James M Snell <jasnell@gmail.com> Reviewed-By: Tobias Nießen <tniessen@tnie.de> Reviewed-By: Colin Ihrig <cjihrig@gmail.com> Reviewed-By: Anna Henningsen <anna@addaleax.net> Reviewed-By: Ruben Bridgewater <ruben@bridgewater.de>

view details

Rich Trott

commit sha e23b12e130e2a16d518754cbbd7c333b82ae2361

doc: reword possessive form of Node.js in zlib.md Throughout the docs, we sometimes write the possessive of _Node.js_ as _Node.js'_ and other times as _Node.js's_. The former conforms with some generally accepted style guides (e.g., Associated Press Stylebook) while the latter complies with others (e.g., Chicago Manual of Style). Since there is no clear authoritative answer as to which form is correct, and since (at least to me) both are visually jarring and sometimes cause a pause to understand, I'd like to reword things to eliminate the possessive form where possible. This is one of those examples. PR-URL: https://github.com/nodejs/node/pull/31713 Reviewed-By: Ben Noordhuis <info@bnoordhuis.nl> Reviewed-By: Beth Griggs <Bethany.Griggs@uk.ibm.com> Reviewed-By: James M Snell <jasnell@gmail.com> Reviewed-By: Tobias Nießen <tniessen@tnie.de> Reviewed-By: Colin Ihrig <cjihrig@gmail.com> Reviewed-By: Anna Henningsen <anna@addaleax.net> Reviewed-By: Ruben Bridgewater <ruben@bridgewater.de>

view details

Derek Lewis

commit sha a751389a14ddb3571e3ade22ac472b9aeb912bc0

tools: update Markdown linter to be cross-platform Prior to this commit, the dependencies were not matching the build procedure. This has been corrected and it has the added benefit of being able to be built on Windows as well. * continue using `rollup` rather than `ncc` * do not require `fs-event`s for non-macOS * use `npx` and `shx` for cross-platform building * ensure `lint-md-rollup` runs before `lint-md` PR-URL: https://github.com/nodejs/node/pull/31239 Reviewed-By: Rich Trott <rtrott@gmail.com>

view details

ZYSzys

commit sha 3e9302b2b34ab0309de8eda45c17efc8fd9cc2f5

fs: validate the input data before opening file PR-URL: https://github.com/nodejs/node/pull/31731 Refs: https://github.com/nodejs/node/pull/31030 Reviewed-By: Ruben Bridgewater <ruben@bridgewater.de> Reviewed-By: Colin Ihrig <cjihrig@gmail.com> Reviewed-By: Luigi Pinca <luigipinca@gmail.com> Reviewed-By: Anna Henningsen <anna@addaleax.net> Reviewed-By: Denys Otrishko <shishugi@gmail.com>

view details

Denys Otrishko

commit sha 84b8857098b2a846855bb2420f3a1144ef68cce3

src: allow to reuse env options handling PR-URL: https://github.com/nodejs/node/pull/31711 Reviewed-By: Anna Henningsen <anna@addaleax.net> Reviewed-By: Benjamin Gruenbaum <benjamingr@gmail.com>

view details

Denys Otrishko

commit sha d63bcdd9cd81b10b6158f40d44bf6f37e5f54385

worker: properly handle env and NODE_OPTIONS in workers PR-URL: https://github.com/nodejs/node/pull/31711 Fixes: https://github.com/nodejs/node/issues/30627 Reviewed-By: Anna Henningsen <anna@addaleax.net> Reviewed-By: Benjamin Gruenbaum <benjamingr@gmail.com>

view details

Ben Noordhuis

commit sha b32fa7bcc69aec0acb63792c799a22eeae7424c6

src: add ExclusiveAccess class Similar to Rust's `std::sync::Mutex` in that it requires one to unwrap the object before accessing it, acquiring the mutex in the process. PR-URL: https://github.com/nodejs/node/pull/31717 Reviewed-By: James M Snell <jasnell@gmail.com> Reviewed-By: Colin Ihrig <cjihrig@gmail.com> Reviewed-By: Anna Henningsen <anna@addaleax.net> Reviewed-By: Tobias Nießen <tniessen@tnie.de> Reviewed-By: David Carlier <devnexen@gmail.com>

view details

Ben Noordhuis

commit sha 303e2fdc598cbc82af401f12f3cc9169ed31598b

src: wrap HostPort in ExclusiveAccess I found it exceedingly hard to figure out if there is a race condition where one thread reads the inspector agent's HostPort's properties while another modifies them concurrently. I think the answer is "no, there isn't" but with this commit use sites are forced to unwrap the object (and acquire the mutex in the process), making it a great deal easier to reason about correctness. PR-URL: https://github.com/nodejs/node/pull/31717 Reviewed-By: James M Snell <jasnell@gmail.com> Reviewed-By: Colin Ihrig <cjihrig@gmail.com> Reviewed-By: Anna Henningsen <anna@addaleax.net> Reviewed-By: Tobias Nießen <tniessen@tnie.de> Reviewed-By: David Carlier <devnexen@gmail.com>

view details

Rich Trott

commit sha 481fa1ca989a36f850f844f1df50a6db0cfb1dd3

util: add coverage for util.inspect.colors alias setter Add test to confirm that the setter for aliases in `util.inspect.colors` keeps the alias reference-equal to the target value. Refs: https://coverage.nodejs.org/coverage-5b0308cd823a5110/lib/internal/util/inspect.js.html#L357 Refs: https://codecov.io/gh/nodejs/node/src/5b0308cd823a511098dadf9ddd5a35e3a9dbb424/lib/internal/util/inspect.js#L357 PR-URL: https://github.com/nodejs/node/pull/31743 Reviewed-By: James M Snell <jasnell@gmail.com> Reviewed-By: Anna Henningsen <anna@addaleax.net>

view details

Rich Trott

commit sha a18b437e6a6115e30309a1f200f614e27e650aa4

util: throw if unreachable TypedArray checking code is reached If a comparison code path that is supposed to be unreachable is reached, throw. Add a c8 comment to ignore coverage for the line, as it should be unreachable. PR-URL: https://github.com/nodejs/node/pull/31737 Reviewed-By: Ruben Bridgewater <ruben@bridgewater.de> Reviewed-By: Anna Henningsen <anna@addaleax.net> Reviewed-By: James M Snell <jasnell@gmail.com> Reviewed-By: Luigi Pinca <luigipinca@gmail.com>

view details

Rich Trott

commit sha a3eb6f2b5255d87ea5e207598ef87be5be204eba

meta: move calvinmetcalf to emeritus calvinmetcalf confirmed in email that moving to emeritus seemed like the right move for them right now. Move a separate entry that wasn't in the correct place in the list. PR-URL: https://github.com/nodejs/node/pull/31736 Reviewed-By: Colin Ihrig <cjihrig@gmail.com> Reviewed-By: James M Snell <jasnell@gmail.com> Reviewed-By: Luigi Pinca <luigipinca@gmail.com> Reviewed-By: Ruben Bridgewater <ruben@bridgewater.de> Reviewed-By: Richard Lau <riclau@uk.ibm.com> Reviewed-By: Gireesh Punathil <gpunathi@in.ibm.com> Reviewed-By: Michaël Zasso <targos@protonmail.com> Reviewed-By: Calvin Metcalf <calvin.metcalf@gmail.com>

view details

Rich Trott

commit sha c3cebf55129d5337cc446163d63ae1405069595c

meta: move vkurchatkin to emeritus vkurchatkin confirmed in email that it's time to move to emeritus. PR-URL: https://github.com/nodejs/node/pull/31729 Reviewed-By: Gus Caplan <me@gus.host> Reviewed-By: Yongsheng Zhang <zyszys98@gmail.com> Reviewed-By: Ruben Bridgewater <ruben@bridgewater.de> Reviewed-By: Colin Ihrig <cjihrig@gmail.com> Reviewed-By: James M Snell <jasnell@gmail.com> Reviewed-By: Gireesh Punathil <gpunathi@in.ibm.com> Reviewed-By: Michaël Zasso <targos@protonmail.com>

view details

Rich Trott

commit sha ff82b76ff044ea66f2f7155a1b154e333b827b6d

meta: move princejwesley to emeritus princejwesley confirmed in email that moving to emeritus at this time was appropriate. PR-URL: https://github.com/nodejs/node/pull/31730 Reviewed-By: Gus Caplan <me@gus.host> Reviewed-By: Yongsheng Zhang <zyszys98@gmail.com> Reviewed-By: Ruben Bridgewater <ruben@bridgewater.de> Reviewed-By: Colin Ihrig <cjihrig@gmail.com> Reviewed-By: James M Snell <jasnell@gmail.com> Reviewed-By: Gireesh Punathil <gpunathi@in.ibm.com> Reviewed-By: Michaël Zasso <targos@protonmail.com>

view details

Tobias Nießen

commit sha 09b6894fe8b5eb8a0625effdc701d6da765078ab

doc: update foundation name in onboarding PR-URL: https://github.com/nodejs/node/pull/31719 Reviewed-By: Colin Ihrig <cjihrig@gmail.com> Reviewed-By: James M Snell <jasnell@gmail.com> Reviewed-By: Anto Aravinth <anto.aravinth.cse@gmail.com> Reviewed-By: Ruben Bridgewater <ruben@bridgewater.de>

view details

Anna Henningsen

commit sha 5e41765f47a4dfb519047428026dff9be4f7e0a9

doc: expand C++ README with information about exception handling Add more information about why it is advisable not to use `.FromJust()` etc. on Maybe(Local)s, and general information about termination exceptions. PR-URL: https://github.com/nodejs/node/pull/31720 Reviewed-By: Colin Ihrig <cjihrig@gmail.com> Reviewed-By: Sam Roberts <vieuxtech@gmail.com> Reviewed-By: James M Snell <jasnell@gmail.com> Reviewed-By: Denys Otrishko <shishugi@gmail.com> Reviewed-By: Ruben Bridgewater <ruben@bridgewater.de>

view details

Danielle Adams

commit sha e5e011d9bc71c7d651db47950a5af0e738f68784

doc: add directions to mark a release line as lts Moves directions for LTS release from the Release repo to Node docs. Fixes: https://github.com/nodejs/Release/issues/530 PR-URL: https://github.com/nodejs/node/pull/31724 Reviewed-By: Richard Lau <riclau@uk.ibm.com> Reviewed-By: James M Snell <jasnell@gmail.com> Reviewed-By: Ruben Bridgewater <ruben@bridgewater.de> Reviewed-By: Myles Borins <myles.borins@gmail.com> Reviewed-By: Beth Griggs <Bethany.Griggs@uk.ibm.com> Reviewed-By: Anna Henningsen <anna@addaleax.net>

view details

push time in 6 days

issue commentnodejs/admin

unblock translation process

In the screenshot, it says "set up integration via access token only if you have limited or no access to the GitHub repository". What would be the other way to set it up?

Trott

comment created time in 7 days

push eventnodejs/node

Robert Nagy

commit sha df1592d2e9935305539c909fecabcb96e3dd8aee

test: async iterate destroyed stream PR-URL: https://github.com/nodejs/node/pull/28995 Reviewed-By: Anna Henningsen <anna@addaleax.net> Reviewed-By: James M Snell <jasnell@gmail.com> Reviewed-By: Trivikram Kamat <trivikr.dev@gmail.com>

view details

legendecas

commit sha 75311dbc2f5fbd1c81dbab94e1372b55e0dbb1ac

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>

view details

Anna Henningsen

commit sha e460f8cf43863a5a8d73273ce311135ad3245699

src: keep main-thread Isolate attached to platform during Dispose This works around a situation in which the V8 WASM code calls into the platform while the Isolate is being disposed. This goes against the V8 API constract for `v8::Platform`. In lieu of a proper fix, it should be okay to keep the Isolate registered; the race condition fixed by 25447d82d cannot occur for the `NodeMainInstance`’s Isolate, as it is the last one to exit in any given Node.js process. This partially reverts 25447d82d. Refs: https://github.com/nodejs/node/pull/30909 Refs: https://github.com/nodejs/node/issues/31752 PR-URL: https://github.com/nodejs/node/pull/31795 Reviewed-By: Denys Otrishko <shishugi@gmail.com> Reviewed-By: James M Snell <jasnell@gmail.com>

view details

Shelley Vohr

commit sha 3a2254959b9e8c5177289ab1c1259f18ceaf9449

src: use hex not decimal in IsArrayIndex PR-URL: https://github.com/nodejs/node/pull/31758 Reviewed-By: James M Snell <jasnell@gmail.com> Reviewed-By: Colin Ihrig <cjihrig@gmail.com> Reviewed-By: David Carlier <devnexen@gmail.com> Reviewed-By: Denys Otrishko <shishugi@gmail.com> Reviewed-By: Anna Henningsen <anna@addaleax.net>

view details

Michael Dawson

commit sha 79296dc2d02c0b9872bbfcbb89148ea036a546d0

doc: guide - using valgrind to debug memory leaks Add doc for using valgrind to debug native memory leaks. Started writing this up as part of an effort in the Diagnostic WG but think it's better to have it in the core guides and then be referenced by the docs in the Diagnostic WG repo. For more details on the Diagnostic WG effort see https://github.com/nodejs/diagnostics/issues/254#issuecomment-538853390 This guide is related to `/step3 - using_native_tools.md` PR-URL: https://github.com/nodejs/node/pull/31501 Reviewed-By: Gireesh Punathil <gpunathi@in.ibm.com> Reviewed-By: Denys Otrishko <shishugi@gmail.com> Reviewed-By: James M Snell <jasnell@gmail.com>

view details

Anna Henningsen

commit sha a7c523e26df468782691c7e16b2e033c6256beb3

src: prefer 3-argument Array::New() This is nicer, because: 1. It reduces overall code size, 2. It’s faster, because `Object::Set()` calls are relatively slow, and 3. It helps avoid invalid `.Check()`/`.FromJust()` calls. PR-URL: https://github.com/nodejs/node/pull/31775 Reviewed-By: James M Snell <jasnell@gmail.com> Reviewed-By: Ben Noordhuis <info@bnoordhuis.nl> Reviewed-By: Colin Ihrig <cjihrig@gmail.com> Reviewed-By: David Carlier <devnexen@gmail.com>

view details

Robert Nagy

commit sha c776a37791007e0d570355b731647e58ea5885be

http: end with data can cause write after end Calling end() with data while ending should trigger a write after end error. PR-URL: https://github.com/nodejs/node/pull/28666 Reviewed-By: Luigi Pinca <luigipinca@gmail.com> Reviewed-By: Benjamin Gruenbaum <benjamingr@gmail.com> Reviewed-By: James M Snell <jasnell@gmail.com> Reviewed-By: Trivikram Kamat <trivikr.dev@gmail.com> Reviewed-By: Matteo Collina <matteo.collina@gmail.com> Reviewed-By: Rich Trott <rtrott@gmail.com>

view details

Robert Nagy

commit sha 568fdfb1658bfcaa7832759e03661f2cb958c155

fs: fix WriteStream autoClose order WriteStream autoClose was implemented by manually calling .destroy() instead of using autoDestroy and callback. This caused some invariants related to order of events to be broken. Fixes: https://github.com/nodejs/node/issues/31776 PR-URL: https://github.com/nodejs/node/pull/31790 Reviewed-By: Matteo Collina <matteo.collina@gmail.com> Reviewed-By: James M Snell <jasnell@gmail.com> Reviewed-By: Luigi Pinca <luigipinca@gmail.com>

view details

Samuel Attard

commit sha 093639614fa1cea7a1bc3493d28119a924c97bc9

doc: claim ABI version 82 for Electron 10 PR-URL: https://github.com/nodejs/node/pull/31778 Reviewed-By: Richard Lau <riclau@uk.ibm.com> Reviewed-By: Anna Henningsen <anna@addaleax.net> Reviewed-By: Benjamin Gruenbaum <benjamingr@gmail.com> Reviewed-By: Colin Ihrig <cjihrig@gmail.com> Reviewed-By: James M Snell <jasnell@gmail.com> Reviewed-By: Jiawen Geng <technicalcute@gmail.com> Reviewed-By: Michaël Zasso <targos@protonmail.com> Reviewed-By: Myles Borins <myles.borins@gmail.com> Reviewed-By: Luigi Pinca <luigipinca@gmail.com>

view details

Anna Henningsen

commit sha 26e49d83323c78e89b2664b6eeaee90757d52868

worker: unroll file extension regexp Refs: https://github.com/nodejs/node/pull/31662#discussion_r377016190 PR-URL: https://github.com/nodejs/node/pull/31779 Reviewed-By: Richard Lau <riclau@uk.ibm.com> Reviewed-By: Benjamin Gruenbaum <benjamingr@gmail.com> Reviewed-By: Denys Otrishko <shishugi@gmail.com> Reviewed-By: Gus Caplan <me@gus.host> Reviewed-By: Colin Ihrig <cjihrig@gmail.com> Reviewed-By: James M Snell <jasnell@gmail.com> Reviewed-By: Yongsheng Zhang <zyszys98@gmail.com> Reviewed-By: Ruben Bridgewater <ruben@bridgewater.de>

view details

Jeff

commit sha e028ea0291b845e4bec3c7cff7319a027b8c815e

doc: fix typos in doc/api/https.md PR-URL: https://github.com/nodejs/node/pull/31793 Reviewed-By: Michaël Zasso <targos@protonmail.com> Reviewed-By: James M Snell <jasnell@gmail.com> Reviewed-By: Yongsheng Zhang <zyszys98@gmail.com> Reviewed-By: Luigi Pinca <luigipinca@gmail.com> Reviewed-By: Colin Ihrig <cjihrig@gmail.com> Reviewed-By: Richard Lau <riclau@uk.ibm.com>

view details

Jeremiah Senkpiel

commit sha 4d6c861800cc6ac1dc6a0fd9d3a8b0053baec62a

doc: move @Fishrock123 to a previous releaser I have not done a release in well over a year, maybe even two. I also don't really plan to do more, as Node.js releases are very tedious. PR-URL: https://github.com/nodejs/node/pull/31725 Reviewed-By: Matteo Collina <matteo.collina@gmail.com> Reviewed-By: Daniel Bevenius <daniel.bevenius@gmail.com> Reviewed-By: James M Snell <jasnell@gmail.com> Reviewed-By: Myles Borins <myles.borins@gmail.com> Reviewed-By: Anna Henningsen <anna@addaleax.net> Reviewed-By: Anto Aravinth <anto.aravinth.cse@gmail.com> Reviewed-By: Colin Ihrig <cjihrig@gmail.com> Reviewed-By: Tobias Nießen <tniessen@tnie.de> Reviewed-By: Gus Caplan <me@gus.host> Reviewed-By: Gireesh Punathil <gpunathi@in.ibm.com> Reviewed-By: Michael Dawson <michael_dawson@ca.ibm.com>

view details

Jeremiah Senkpiel

commit sha 928c210a611fb6b4575843708e7cb921f311ebde

doc: move @Fishrock123 to TSC Emeriti It was a good run. Almost 5 years. I haven't really been involved in the last 3+? months though, so it's time I call it and 'retire'. I think it is unlikely that I'll be on the TSC again, as node is unfortunately becoming increasingly disinteresting (& frustrating) to me. (So long and thanks for all the fish!) PR-URL: https://github.com/nodejs/node/pull/31725 Reviewed-By: Matteo Collina <matteo.collina@gmail.com> Reviewed-By: Daniel Bevenius <daniel.bevenius@gmail.com> Reviewed-By: James M Snell <jasnell@gmail.com> Reviewed-By: Myles Borins <myles.borins@gmail.com> Reviewed-By: Anna Henningsen <anna@addaleax.net> Reviewed-By: Anto Aravinth <anto.aravinth.cse@gmail.com> Reviewed-By: Colin Ihrig <cjihrig@gmail.com> Reviewed-By: Tobias Nießen <tniessen@tnie.de> Reviewed-By: Gus Caplan <me@gus.host> Reviewed-By: Gireesh Punathil <gpunathi@in.ibm.com> Reviewed-By: Michael Dawson <michael_dawson@ca.ibm.com>

view details

Jeremiah Senkpiel

commit sha 30e6049c75590dec8d5edbf033edbc20e79efcb7

doc: pronouns for @Fishrock123 might as well while I'm at it feels a bit weird being the first person on this list with '/they' but I guess someone's gota do it PR-URL: https://github.com/nodejs/node/pull/31725 Reviewed-By: Matteo Collina <matteo.collina@gmail.com> Reviewed-By: Daniel Bevenius <daniel.bevenius@gmail.com> Reviewed-By: James M Snell <jasnell@gmail.com> Reviewed-By: Myles Borins <myles.borins@gmail.com> Reviewed-By: Anna Henningsen <anna@addaleax.net> Reviewed-By: Anto Aravinth <anto.aravinth.cse@gmail.com> Reviewed-By: Colin Ihrig <cjihrig@gmail.com> Reviewed-By: Tobias Nießen <tniessen@tnie.de> Reviewed-By: Gus Caplan <me@gus.host> Reviewed-By: Gireesh Punathil <gpunathi@in.ibm.com> Reviewed-By: Michael Dawson <michael_dawson@ca.ibm.com>

view details

Gireesh Punathil

commit sha 4c746a6cfda980c1cd0de6246781c0083d9e416c

doc: move gireeshpunathil to TSC emeritus PR-URL: https://github.com/nodejs/node/pull/31770 Reviewed-By: James M Snell <jasnell@gmail.com> Reviewed-By: Myles Borins <myles.borins@gmail.com> Reviewed-By: Luigi Pinca <luigipinca@gmail.com> Reviewed-By: Colin Ihrig <cjihrig@gmail.com> Reviewed-By: Tobias Nießen <tniessen@tnie.de> Reviewed-By: Richard Lau <riclau@uk.ibm.com> Reviewed-By: Michael Dawson <michael_dawson@ca.ibm.com>

view details

James M Snell

commit sha 5bef2ccf20cceda7975f8bce860e0f60595482fc

test: add known issue test for sync writable callback If the write callbacks are invoked synchronously with an error, onwriteError would cause the error event to be emitted synchronously, making it impossible to attach an error handler after the call that triggered it. PR-URL: https://github.com/nodejs/node/pull/31756 Refs: https://github.com/nodejs/quic/commit/b0d469c69c49c9186c1a581a7cebce4c5d398947 Refs: https://github.com/nodejs/quic/pull/341 Reviewed-By: Robert Nagy <ronagy@icloud.com> Reviewed-By: Matteo Collina <matteo.collina@gmail.com> Reviewed-By: Anna Henningsen <anna@addaleax.net> Reviewed-By: Minwoo Jung <nodecorelab@gmail.com>

view details

Robert Nagy

commit sha 85c6fcd1cd11ec6ee22891e48a67cc97f60880e8

stream: avoid writing to writable A remainder from a previous refactoring. Refs: https://github.com/nodejs/node/pull/31197 PR-URL: https://github.com/nodejs/node/pull/31805 Reviewed-By: Luigi Pinca <luigipinca@gmail.com> Reviewed-By: Matteo Collina <matteo.collina@gmail.com> Reviewed-By: James M Snell <jasnell@gmail.com>

view details

Rich Trott

commit sha 99428e0858bb3cce820190770ca8217460d95c80

doc: reword possessive form of Node.js in debugger.md Throughout the docs, we sometimes write the possessive of _Node.js_ as _Node.js'_ and other times as _Node.js's_. The former conforms with some generally accepted style guides (e.g., Associated Press Stylebook) while the latter complies with others (e.g., Chicago Manual of Style). Since there is no clear authoritative answer as to which form is correct, and since (at least to me) both are visually jarring and sometimes cause a pause to understand, I'd like to reword things to eliminate the possessive form where possible. This is one of those examples. PR-URL: https://github.com/nodejs/node/pull/31748 Reviewed-By: Benjamin Gruenbaum <benjamingr@gmail.com> Reviewed-By: Tobias Nießen <tniessen@tnie.de> Reviewed-By: Luigi Pinca <luigipinca@gmail.com> Reviewed-By: Richard Lau <riclau@uk.ibm.com> Reviewed-By: Michael Dawson <michael_dawson@ca.ibm.com>

view details

Rich Trott

commit sha d40c648e884bd64028fa0a67122a0af87c60f467

doc: reword possessive form of Node.js in process.md Throughout the docs, we sometimes write the possessive of _Node.js_ as _Node.js'_ and other times as _Node.js's_. The former conforms with some generally accepted style guides (e.g., Associated Press Stylebook) while the latter complies with others (e.g., Chicago Manual of Style). Since there is no clear authoritative answer as to which form is correct, and since (at least to me) both are visually jarring and sometimes cause a pause to understand, I'd like to reword things to eliminate the possessive form where possible. This is one of those examples. PR-URL: https://github.com/nodejs/node/pull/31748 Reviewed-By: Benjamin Gruenbaum <benjamingr@gmail.com> Reviewed-By: Tobias Nießen <tniessen@tnie.de> Reviewed-By: Luigi Pinca <luigipinca@gmail.com> Reviewed-By: Richard Lau <riclau@uk.ibm.com> Reviewed-By: Michael Dawson <michael_dawson@ca.ibm.com>

view details

Rich Trott

commit sha d25fcb0c201286d18c07653347258ce02951ddf8

doc: reword possessive form of Node.js in http.md Throughout the docs, we sometimes write the possessive of _Node.js_ as _Node.js'_ and other times as _Node.js's_. The former conforms with some generally accepted style guides (e.g., Associated Press Stylebook) while the latter complies with others (e.g., Chicago Manual of Style). Since there is no clear authoritative answer as to which form is correct, and since (at least to me) both are visually jarring and sometimes cause a pause to understand, I'd like to reword things to eliminate the possessive form where possible. This is one of those examples. PR-URL: https://github.com/nodejs/node/pull/31748 Reviewed-By: Benjamin Gruenbaum <benjamingr@gmail.com> Reviewed-By: Tobias Nießen <tniessen@tnie.de> Reviewed-By: Luigi Pinca <luigipinca@gmail.com> Reviewed-By: Richard Lau <riclau@uk.ibm.com> Reviewed-By: Michael Dawson <michael_dawson@ca.ibm.com>

view details

push time in 7 days

issue commentnodejs/node

Verification with dsaEncoding ieee-p1363 fails.

@nodejs/crypto

wdenbakker

comment created time in 8 days

pull request commentnodejs/node

tools: sync gyp code base with node-gyp repo

Other PR landed on node-gyp. This should be ready to go.

targos

comment created time in 8 days

push eventtargos/node

Daniel Bevenius

commit sha d227d22bd9653f201e182efb76f2a5fe6a93f955

src: fix minor typo in base_object.h PR-URL: https://github.com/nodejs/node/pull/31535 Reviewed-By: Anna Henningsen <anna@addaleax.net> Reviewed-By: Colin Ihrig <cjihrig@gmail.com> Reviewed-By: David Carlier <devnexen@gmail.com> Reviewed-By: James M Snell <jasnell@gmail.com> Reviewed-By: Rich Trott <rtrott@gmail.com>

view details

Robert Nagy

commit sha 1d9511127c419ec116b3ddf5fc7a59e8f0f1c1e4

doc: update collaborator guide citgm instructions PR-URL: https://github.com/nodejs/node/pull/31549 Reviewed-By: Anna Henningsen <anna@addaleax.net> Reviewed-By: Richard Lau <riclau@uk.ibm.com> Reviewed-By: James M Snell <jasnell@gmail.com> Reviewed-By: Rich Trott <rtrott@gmail.com> Reviewed-By: Luigi Pinca <luigipinca@gmail.com> Reviewed-By: Beth Griggs <Bethany.Griggs@uk.ibm.com>

view details

Sam Roberts

commit sha 38aa31554c2a71ae17ed4971f9f2b4a9ab514118

doc: simultaneous blog and email of sec announce PR-URL: https://github.com/nodejs/node/pull/31483 Reviewed-By: Rich Trott <rtrott@gmail.com> Reviewed-By: Michael Dawson <michael_dawson@ca.ibm.com>

view details

Richard Lau

commit sha d4c81be4a0035b2d96cd62ae3a846d4435d941e6

doc: update job reference in COLLABORATOR_GUIDE.md https://ci.nodejs.org/job/node-test-commit-custom-suites/ is disabled in Jenkins with a note to instead use https://ci.nodejs.org/job/node-test-commit-custom-suites-freestyle/. Update the guide to remove the layer of indirection. PR-URL: https://github.com/nodejs/node/pull/31557 Reviewed-By: Colin Ihrig <cjihrig@gmail.com> Reviewed-By: Luigi Pinca <luigipinca@gmail.com> Reviewed-By: Michael Dawson <michael_dawson@ca.ibm.com> Reviewed-By: Trivikram Kamat <trivikr.dev@gmail.com> Reviewed-By: James M Snell <jasnell@gmail.com> Reviewed-By: Rich Trott <rtrott@gmail.com>

view details

aaccttrr

commit sha 9225939528590f652e6ee1ccf73e709b029d4ca5

worker: remove redundant closing of child port PR-URL: https://github.com/nodejs/node/pull/31555 Reviewed-By: Anna Henningsen <anna@addaleax.net> Reviewed-By: Colin Ihrig <cjihrig@gmail.com> Reviewed-By: James M Snell <jasnell@gmail.com> Reviewed-By: David Carlier <devnexen@gmail.com> Reviewed-By: Rich Trott <rtrott@gmail.com>

view details

Anna Henningsen

commit sha abe6a2e3d1c268f5bebbf05864f2588c6f4858b5

process: report ArrayBuffer memory in `memoryUsage()` Report memory allocations performed by the `ArrayBuffer::Allocator`. PR-URL: https://github.com/nodejs/node/pull/31550 Reviewed-By: Richard Lau <riclau@uk.ibm.com> Reviewed-By: Colin Ihrig <cjihrig@gmail.com> Reviewed-By: Gus Caplan <me@gus.host> Reviewed-By: Ben Noordhuis <info@bnoordhuis.nl> Reviewed-By: James M Snell <jasnell@gmail.com> Reviewed-By: Rich Trott <rtrott@gmail.com> Reviewed-By: Gireesh Punathil <gpunathi@in.ibm.com>

view details

Anna Henningsen

commit sha dd4c62eabe1f5cf982137d9d826aac162a611d26

doc: clarify that `v8.serialize()` is not deterministic Fixes: https://github.com/nodejs/help/issues/2448 PR-URL: https://github.com/nodejs/node/pull/31548 Reviewed-By: Colin Ihrig <cjihrig@gmail.com> Reviewed-By: Gus Caplan <me@gus.host> Reviewed-By: James M Snell <jasnell@gmail.com> Reviewed-By: Rich Trott <rtrott@gmail.com> Reviewed-By: Luigi Pinca <luigipinca@gmail.com>

view details

Tobias Nießen

commit sha a17131400360562f06fc4d1c217ee60f7c5928aa

n-api: rename 'promise' parameter to 'value' This change makes it clear that the value doesn't need to be a Promise, and makes the signature consistent with other napi_is_* functions. PR-URL: https://github.com/nodejs/node/pull/31544 Reviewed-By: Chengzhong Wu <legendecas@gmail.com> Reviewed-By: Anna Henningsen <anna@addaleax.net> Reviewed-By: David Carlier <devnexen@gmail.com> Reviewed-By: Colin Ihrig <cjihrig@gmail.com> Reviewed-By: James M Snell <jasnell@gmail.com> Reviewed-By: Rich Trott <rtrott@gmail.com>

view details

Gus Caplan

commit sha 43fb6ffef7a14b47d1b0ba8134102795f5017a59

build: enable loading internal modules from disk PR-URL: https://github.com/nodejs/node/pull/31321 Reviewed-By: Anna Henningsen <anna@addaleax.net> Reviewed-By: Tobias Nießen <tniessen@tnie.de> Reviewed-By: Joyee Cheung <joyeec9h3@gmail.com> Reviewed-By: Rich Trott <rtrott@gmail.com> Reviewed-By: Colin Ihrig <cjihrig@gmail.com> Reviewed-By: Matteo Collina <matteo.collina@gmail.com>

view details

bcoe

commit sha 13fe56bbbbc290cbc16804994ce0ec1d25729775

fs: return first folder made by mkdir recursive mkdir('/foo/bar', { recursive: true }) and mkdirSync will now return the path of the first folder created. This matches more closely mkdirp's behavior, and is useful for setting folder permissions. PR-URL: https://github.com/nodejs/node/pull/31530 Refs: https://github.com/nodejs/node/issues/31481 Reviewed-By: James M Snell <jasnell@gmail.com> Reviewed-By: Anna Henningsen <anna@addaleax.net> Reviewed-By: Rich Trott <rtrott@gmail.com>

view details

Harshitha KP

commit sha 25c3f7c61a167c152c10afda68a2d39161179e77

test: remove --experimental-worker flag comment worker is stable in the master branch. The flag is no longer required. PR-URL: https://github.com/nodejs/node/pull/31563 Reviewed-By: Richard Lau <riclau@uk.ibm.com> Reviewed-By: Anna Henningsen <anna@addaleax.net> Reviewed-By: Yongsheng Zhang <zyszys98@gmail.com> Reviewed-By: Colin Ihrig <cjihrig@gmail.com> Reviewed-By: Trivikram Kamat <trivikr.dev@gmail.com> Reviewed-By: James M Snell <jasnell@gmail.com> Reviewed-By: Rich Trott <rtrott@gmail.com>

view details

Michael Lumish

commit sha 470511ae781f152ac53a192c7bb0f395c972d200

doc: add protocol option in http2.connect() This option is used here: https://github.com/nodejs/node/blob/70c32a6d190e2b5d7b9ff9d5b6a459d14e8b7d59/lib/internal/http2/core.js#L3010 PR-URL: https://github.com/nodejs/node/pull/31560 Reviewed-By: Colin Ihrig <cjihrig@gmail.com> Reviewed-By: Luigi Pinca <luigipinca@gmail.com> Reviewed-By: Trivikram Kamat <trivikr.dev@gmail.com> Reviewed-By: James M Snell <jasnell@gmail.com> Reviewed-By: Rich Trott <rtrott@gmail.com>

view details

Michael Perrotte

commit sha 54c1a09202e68517d826104bad3e8e787d358197

deps: upgrade npm to 6.13.7 PR-URL: https://github.com/nodejs/node/pull/31558 Reviewed-By: Colin Ihrig <cjihrig@gmail.com> Reviewed-By: Trivikram Kamat <trivikr.dev@gmail.com> Reviewed-By: Rich Trott <rtrott@gmail.com>

view details

Denys Otrishko

commit sha be6596352b2a1b8648dc266b5be81b6a1be180d6

doc: clarify require() OS independence PR-URL: https://github.com/nodejs/node/pull/31571 Reviewed-By: Anna Henningsen <anna@addaleax.net> Reviewed-By: Luigi Pinca <luigipinca@gmail.com> Reviewed-By: Rich Trott <rtrott@gmail.com>

view details

Anna Henningsen

commit sha 023ecbccc8b1e492234e769894fde2967d4a5677

src: remove preview for heap dump utilities At least `createHeapSnapshotStream()` and `triggerHeapSnapshot()` do have side effects, and more importantly, they should not be run transparently. Without this, typing e.g. `v8.getHeapSnapshot()` into the REPL will result in a crash or infinite loop while the REPL evaluates the expression for a preview. PR-URL: https://github.com/nodejs/node/pull/31570 Reviewed-By: Colin Ihrig <cjihrig@gmail.com> Reviewed-By: Gus Caplan <me@gus.host> Reviewed-By: Richard Lau <riclau@uk.ibm.com> Reviewed-By: David Carlier <devnexen@gmail.com> Reviewed-By: James M Snell <jasnell@gmail.com> Reviewed-By: Rich Trott <rtrott@gmail.com>

view details

ConorDavenport

commit sha d10927b687858224558dbe0f10f5c57b4139ad96

build: ignore all the "Debug","Release" folders Since there're still many "Debug" and "Release" folders in "deps" and "tools", to make it more strict and totally ignore the generated obj files, ignore all the files/folders under them. Refs: https://github.com/nodejs/node/pull/27210 PR-URL: https://github.com/nodejs/node/pull/31565 Reviewed-By: Anna Henningsen <anna@addaleax.net> Reviewed-By: David Carlier <devnexen@gmail.com> Reviewed-By: James M Snell <jasnell@gmail.com> Reviewed-By: Rich Trott <rtrott@gmail.com>

view details

Dylan Coakley

commit sha cb210110e9c7e4b8d7c64af4a45d4b1e7d429a0e

test: verify threadId in reports PR-URL: https://github.com/nodejs/node/pull/31556 Reviewed-By: Benjamin Gruenbaum <benjamingr@gmail.com> Reviewed-By: Anna Henningsen <anna@addaleax.net> Reviewed-By: Richard Lau <riclau@uk.ibm.com> Reviewed-By: Colin Ihrig <cjihrig@gmail.com> Reviewed-By: James M Snell <jasnell@gmail.com> Reviewed-By: Chengzhong Wu <legendecas@gmail.com> Reviewed-By: Rich Trott <rtrott@gmail.com> Reviewed-By: Michael Dawson <michael_dawson@ca.ibm.com>

view details

Anna Henningsen

commit sha ab9e89439e8f8699efe6c7786d5a3ba9be2a16a6

benchmark: add MessagePort benchmark Add a raw `MessagePort` benchmark that does not ping back and forth between different threads, unlike the `echo.js` benchmark, as there are some performance differences between single-threaded and multi- threaded operation, and a single-threaded Environment can be somewhat easier to work with when profiling. PR-URL: https://github.com/nodejs/node/pull/31568 Reviewed-By: Colin Ihrig <cjihrig@gmail.com> Reviewed-By: James M Snell <jasnell@gmail.com> Reviewed-By: Denys Otrishko <shishugi@gmail.com> Reviewed-By: Rich Trott <rtrott@gmail.com>

view details

cjihrig

commit sha 22724894c99845755dfdafc2a87236fc311343f1

doc: list largepage values in --help This commit adds the supported --use-largepages values to the --help menu. PR-URL: https://github.com/nodejs/node/pull/31537 Fixes: https://github.com/nodejs/node/issues/31533 Reviewed-By: Anna Henningsen <anna@addaleax.net> Reviewed-By: Denys Otrishko <shishugi@gmail.com> Reviewed-By: David Carlier <devnexen@gmail.com> Reviewed-By: James M Snell <jasnell@gmail.com> Reviewed-By: Ben Noordhuis <info@bnoordhuis.nl> Reviewed-By: Rich Trott <rtrott@gmail.com>

view details

Rusty Conover

commit sha 0fe810168bef2a53e5ff6b2f7832e372f850e5f3

doc: clarify socket.setNoDelay() explanation Change the description of socket.setNoDelay() to make it clear that sockets have Nagle's algorithm enabled by default. Better document the tradeoff of having the algorithm enabled. Explain the behavior of the function based on the passed arguments. PR-URL: https://github.com/nodejs/node/pull/31541 Reviewed-By: Denys Otrishko <shishugi@gmail.com> Reviewed-By: James M Snell <jasnell@gmail.com> Reviewed-By: Rich Trott <rtrott@gmail.com>

view details

push time in 8 days

push eventtargos/node

SpaceRacet5w2A6l0I

commit sha bd6d6512f02d6fa10a0484577c270bb44f1b750b

build: avoid using CMP for BZ2File Some Python distributions do not support context manager protocol (CMP) for BZ2File. PR-URL: https://github.com/nodejs/node/pull/31198 Reviewed-By: Anna Henningsen <anna@addaleax.net> Reviewed-By: Ben Noordhuis <info@bnoordhuis.nl> Reviewed-By: James M Snell <jasnell@gmail.com> Reviewed-By: Rich Trott <rtrott@gmail.com> Reviewed-By: Christian Clauss <cclauss@me.com>

view details

Sebastien Ahkrin

commit sha 607be0c78a6bd33a105d2a690f6e71264016252c

stream: replace Function.prototype with primordial PR-URL: https://github.com/nodejs/node/pull/31204 Reviewed-By: Colin Ihrig <cjihrig@gmail.com> Reviewed-By: Trivikram Kamat <trivikr.dev@gmail.com> Reviewed-By: James M Snell <jasnell@gmail.com> Reviewed-By: Ruben Bridgewater <ruben@bridgewater.de> Reviewed-By: Rich Trott <rtrott@gmail.com> Reviewed-By: Jiawen Geng <technicalcute@gmail.com>

view details

legendecas

commit sha b3b0ae565ab6155258eeae00b18e532f3303623d

benchmark: benchmarking impacts of async hooks on promises PR-URL: https://github.com/nodejs/node/pull/31188 Refs: https://github.com/nodejs/diagnostics/issues/124 Reviewed-By: Anna Henningsen <anna@addaleax.net> Reviewed-By: Denys Otrishko <shishugi@gmail.com> Reviewed-By: Rich Trott <rtrott@gmail.com> Reviewed-By: Ruben Bridgewater <ruben@bridgewater.de>

view details

gengjiawen

commit sha 85ef944f639532b230424b3c6b3a0c35caa80957

win: change to use Python in install tool PR-URL: https://github.com/nodejs/node/pull/31221 Reviewed-By: David Carlier <devnexen@gmail.com> Reviewed-By: Sam Roberts <vieuxtech@gmail.com> Reviewed-By: Richard Lau <riclau@uk.ibm.com> Reviewed-By: Christian Clauss <cclauss@me.com> Reviewed-By: Luigi Pinca <luigipinca@gmail.com> Reviewed-By: Ruben Bridgewater <ruben@bridgewater.de> Reviewed-By: Rich Trott <rtrott@gmail.com>

view details

Adam Majer

commit sha f2a089a754046c1bd950cebefd8bdb2960fdce32

test: fix unit test logging with python3 A logfile must be opened as a text file and encoding is specified. Then it can accept a string. Current behaviour we get, Message: 'ok 2834 sequential/test-worker-prof' Arguments: () --- Logging error --- Traceback (most recent call last): File "/usr/lib64/python3.7/logging/__init__.py", line 1037, in emit stream.write(msg + self.terminator) TypeError: a bytes-like object is required, not 'str' Call stack: File "tools/test.py", line 1734, in <module> sys.exit(Main()) File "tools/test.py", line 1710, in Main if RunTestCases(cases_to_run, options.progress, options.j, options.flaky_tests): File "tools/test.py", line 933, in RunTestCases return progress.Run(tasks) File "tools/test.py", line 141, in Run self.RunSingle(False, 0) File "tools/test.py", line 202, in RunSingle self.HasRun(output) File "tools/test.py", line 365, in HasRun logger.info(' ---') PR-URL: https://github.com/nodejs/node/pull/31156 Reviewed-By: Christian Clauss <cclauss@me.com> Reviewed-By: Ruben Bridgewater <ruben@bridgewater.de> Reviewed-By: Colin Ihrig <cjihrig@gmail.com> Reviewed-By: Richard Lau <riclau@uk.ibm.com> Reviewed-By: David Carlier <devnexen@gmail.com> Reviewed-By: Rich Trott <rtrott@gmail.com> Reviewed-By: Daijiro Wachi <daijiro.wachi@gmail.com>

view details

Andrew Hughes

commit sha 41dd175f6d55a665f4c10d3b66ba701507102265

doc: prefer server vs srv and client vs clt PR-URL: https://github.com/nodejs/node/pull/31224 Reviewed-By: Ruben Bridgewater <ruben@bridgewater.de> Reviewed-By: Sam Roberts <vieuxtech@gmail.com> Reviewed-By: Richard Lau <riclau@uk.ibm.com> Reviewed-By: Beth Griggs <Bethany.Griggs@uk.ibm.com> Reviewed-By: Luigi Pinca <luigipinca@gmail.com> Reviewed-By: Rich Trott <rtrott@gmail.com>

view details

Andrew Hughes

commit sha b0f67f2fc72c8c0418c1caf1de860eace1fe5fe0

test: prefer server over srv PR-URL: https://github.com/nodejs/node/pull/31224 Reviewed-By: Ruben Bridgewater <ruben@bridgewater.de> Reviewed-By: Sam Roberts <vieuxtech@gmail.com> Reviewed-By: Richard Lau <riclau@uk.ibm.com> Reviewed-By: Beth Griggs <Bethany.Griggs@uk.ibm.com> Reviewed-By: Luigi Pinca <luigipinca@gmail.com> Reviewed-By: Rich Trott <rtrott@gmail.com>

view details

antsmartian

commit sha aff6fffec584eb08a6a5e774c5b613fcb073c94c

stream: clean up definition using defineProperties PR-URL: https://github.com/nodejs/node/pull/31236 Refs: https://github.com/nodejs/node/pull/31187 Reviewed-By: Matteo Collina <matteo.collina@gmail.com> Reviewed-By: Ruben Bridgewater <ruben@bridgewater.de> Reviewed-By: Luigi Pinca <luigipinca@gmail.com> Reviewed-By: Rich Trott <rtrott@gmail.com>

view details

Ben Noordhuis

commit sha 93b0e39ce2bbbf35c0e77e6d4b8e0e2d909d21c4

src: remove uses of node::InitializeV8Platform() This requires minor changes to src/env.cc to deal with `node::tracing::AgentWriterHandle::GetTracingController()` now possibly returning a nullptr, because the cctest doesn't set one. It seems plausible to me that embedders won't set one either so that seems like an okay change to make. It avoids embedders having to track down nullptr segfaults. PR-URL: https://github.com/nodejs/node/pull/31245 Refs: https://github.com/nodejs/node/pull/31217 Reviewed-By: David Carlier <devnexen@gmail.com> Reviewed-By: Rich Trott <rtrott@gmail.com> Reviewed-By: Anna Henningsen <anna@addaleax.net>

view details

Ben Noordhuis

commit sha cd4a41c92ed55fe71234f59362e4a334a3c43174

src: remove node::InitializeV8Platform() This API method was introduced in commit 90ae4bd0c9 ("src: add InitializeV8Platform function") from July 2018 but wasn't properly exported and therefore not usable on Windows or with shared library builds. The motivation from the commit log is mainly about making it easier to wire up the cctests and there are better ways to do that. Refs: https://github.com/nodejs/node/pull/31217 PR-URL: https://github.com/nodejs/node/pull/31245 Reviewed-By: David Carlier <devnexen@gmail.com> Reviewed-By: Rich Trott <rtrott@gmail.com> Reviewed-By: Anna Henningsen <anna@addaleax.net>

view details

cjihrig

commit sha d1d71db61be531f657c0e0b3f88dd300776ef709

test: remove unused symlink loop This symlink loop was originally intended to be accessed from a test. Instead, a loop is created by the test itself, but this was unfortunately forgotten about. It's unused, so remove it. PR-URL: https://github.com/nodejs/node/pull/31267 Reviewed-By: Sam Roberts <vieuxtech@gmail.com> Reviewed-By: David Carlier <devnexen@gmail.com> Reviewed-By: Rich Trott <rtrott@gmail.com> Reviewed-By: Anna Henningsen <anna@addaleax.net>

view details

Beth Griggs

commit sha 9d5d4f84e3a54fc585276fd5a74ff592783be6ff

2020-01-09, Version 10.18.1 'Dubnium' (LTS) - http2: fix session memory accounting after pausing (Michael Lehenbauer) [#30684](https://github.com/nodejs/node/pull/30684) - n-api: correct bug in napi_get_last_error (Octavian Soldea) [#28702](https://github.com/nodejs/node/pull/28702) - tools: update tzdata to 2019c (Myles Borins) [#30479](https://github.com/nodejs/node/pull/30479) PR-URL: https://github.com/nodejs/node/pull/31248

view details

Sam Roberts

commit sha e4bff131cae5239b5ffd1c705005f29ba7bf6fa9

test: check that --insecure-http-parser works Test that using --insecure-http-parser will disable validation of invalid characters in HTTP headers. See: - https://github.com/nodejs/node/pull/30567 PR-URL: https://github.com/nodejs/node/pull/31253 Reviewed-By: Richard Lau <riclau@uk.ibm.com> Reviewed-By: Ruben Bridgewater <ruben@bridgewater.de>

view details

Denys Otrishko

commit sha a566c05a4996ddf78f2d4993247ec12f57f1f5f6

test: fix recursive rm test to actually use tmpdir Previously folders were created in the root of the project and would therefore stay there in case of errors. This changes the test to create all directories in the temp directory (`tmpdir.path`). PR-URL: https://github.com/nodejs/node/pull/31250 Reviewed-By: Bryan English <bryan@bryanenglish.com> Reviewed-By: Colin Ihrig <cjihrig@gmail.com> Reviewed-By: Richard Lau <riclau@uk.ibm.com> Reviewed-By: Ruben Bridgewater <ruben@bridgewater.de> Reviewed-By: Rich Trott <rtrott@gmail.com> Reviewed-By: Anna Henningsen <anna@addaleax.net>

view details

Bryan English

commit sha 73a9c37307026e46a818a06cc3a375d4d02e65b7

fs: use async writeFile in FileHandle#appendFile When operating on a FileHandle, the file has already been opened with the flag given as an option to fs.promises.open(). This means defaulting to 'a' has no effect here, and FileHandle#appendFile turns out to exactly be an alias of writeFile. This is now explicit, saving a stack frame, object copy and assignment. PR-URL: https://github.com/nodejs/node/pull/31235 Reviewed-By: Rich Trott <rtrott@gmail.com> Reviewed-By: Anto Aravinth <anto.aravinth.cse@gmail.com>

view details

Bryan English

commit sha d4fc59d0b3c44238eee313acc67bfaff654a0355

doc: correct filehandle.[read|write|append]File() * Remove `mode` and `flag` options for all three functions, since they all ignore those options. * Remove mention of `path` argument for `readFile`, since it isn't actually an option to this method. * Clarify that for file handles, `appendFile` and `writeFile` are equivalent. PR-URL: https://github.com/nodejs/node/pull/31235 Reviewed-By: Rich Trott <rtrott@gmail.com> Reviewed-By: Anto Aravinth <anto.aravinth.cse@gmail.com>

view details

gengjiawen

commit sha 60026c7d9d3cf120de318f16171ebd78c0a08917

src: add build Github Action PR-URL: https://github.com/nodejs/node/pull/31153 Reviewed-By: Christian Clauss <cclauss@me.com> Reviewed-By: Anna Henningsen <anna@addaleax.net> Reviewed-By: Colin Ihrig <cjihrig@gmail.com>

view details

cjihrig

commit sha e468759c7dc21b4706a9efae9eb3ed25bc076c11

src: fix -Wbraced-scalar-init warning PR-URL: https://github.com/nodejs/node/pull/31254 Reviewed-By: Richard Lau <riclau@uk.ibm.com> Reviewed-By: Anna Henningsen <anna@addaleax.net> Reviewed-By: David Carlier <devnexen@gmail.com> Reviewed-By: Jiawen Geng <technicalcute@gmail.com> Reviewed-By: Rich Trott <rtrott@gmail.com> Reviewed-By: James M Snell <jasnell@gmail.com>

view details

Robert Nagy

commit sha 1b8eb22761985ba669897b036fc1889243a57ba2

doc: fix stream async iterator sample The for await loop into writable loop could cause an unhandled exception in the case where we are waiting for data from the async iterable and this no `'error'` handler is registered on the writable. Fixes: https://github.com/nodejs/node/issues/31222 PR-URL: https://github.com/nodejs/node/pull/31252 Reviewed-By: Matteo Collina <matteo.collina@gmail.com> Reviewed-By: Rich Trott <rtrott@gmail.com> Reviewed-By: James M Snell <jasnell@gmail.com>

view details

Robert Nagy

commit sha 5f76f7607e56a84d00d6de0faef93c2848943e72

doc: rename iterator to iterable in examples PR-URL: https://github.com/nodejs/node/pull/31252 Fixes: https://github.com/nodejs/node/issues/31222 Reviewed-By: Matteo Collina <matteo.collina@gmail.com> Reviewed-By: Rich Trott <rtrott@gmail.com> Reviewed-By: James M Snell <jasnell@gmail.com>

view details

push time in 8 days

delete branch nodejs/node-gyp

delete branch : sync-gyp

delete time in 8 days

delete branch cheminfo/generator-cheminfo

delete branch : add-types-jest

delete time in 8 days

push eventcheminfo/generator-cheminfo

Luc Patiny

commit sha ba63e13d0b3e5e409545549f3e8d18ec5d5fca0b

feat: add @types/jest (#24)

view details

push time in 8 days

pull request commentcheminfo/generator-cheminfo

feat: add @types/jest

why do you need it? this generator is not for typescript projects

lpatiny

comment created time in 8 days

push eventcheminfo/chromatography

Michaël Zasso

commit sha 19a724ddd4b11727c59b1aff28bc5b7ffaa4cbe5

chore: update dependencies and move to GitHub actions

view details

push time in 8 days

PR opened adonisjs/logger

fix: make serializers optional in Logger.child
+1 -1

0 comment

1 changed file

pr created time in 8 days

push eventtargos/logger

Michaël Zasso

commit sha ef5d03ef7a4efdcb489ef585586ab76afaec1f60

fix: make serializers optional in Logger.child

view details

push time in 8 days

fork targos/logger

Logger built on top of pino to be used by AdonisJs

fork in 8 days

issue commentnodejs/Release

v12.16.0 post-mortem

@addaleax I agree with everything you wrote. I was trying to see if we could do better when porting changes that are already in master/current, but it's even better if the problem never lands anywhere :)

targos

comment created time in 8 days

issue commentnodejs/node

'constructor' bug

What other strings should not be used in an empty object, except 'constructor'?

All keys that exists on Object.prototype.

If you want a really "empty" object, you can create one with Object.create(null). This will set the object's prototype to null and so the object won't inherit any property.

mbykov

comment created time in 8 days

issue openednodejs/Release

v12.16.0 post-mortem

Trying to document what went wrong with v12.16.0 (regressions) and what could be done in the future to reduce the risks.

ESM: Package self-resolution not behind --experimental-modules flag #31754.

  • The feature initially landed with its own flag, --experimental-resolve-self (https://github.com/nodejs/node/pull/29327).
  • The flag was then removed in https://github.com/nodejs/node/pull/31002 but --experimental-conditional-exports was still required to use the feature.
  • https://github.com/nodejs/node/pull/31001 removed the --experimental-conditional-exports flag.
  • When #31002 and #31001 landed, ESM was already unflagged on master/v13.x.

v12.16.0 included a lot of changes related to ESM and because the unflagging is the only thing that we did not backport, we couldn't know exactly which code paths will work differently. For future ESM backports, I suggest that we actively focus on making sure it is flagged.

V8 WASM bug #31752

Uncovered after https://github.com/nodejs/node/pull/30909 landed in v12.16.0. The change was initially released in v13.5.0 but no issue was reported before we included it in v12.16.0.

Because this is a V8 bug that we were not aware of at the time of the release, I don't think we could have done better here, especially since the original change was supposed to fix a regression.

large pages change breaks the build in some cases #31249, #31520

Introduced by https://github.com/nodejs/node/pull/30954. The second issue was fixed on master in https://github.com/nodejs/node/pull/31547 but isn't released yet. There seems to be no fix for the first issue at the moment.

The problem here is that none of the issues were linked back to the PR that introduced them. They do not appear in the PR's timeline. To avoid this happening again, I think we need somehow to instruct collaborators to do these when a regression is found:

  • Comment on the PR with a link to the new issue
  • If the PR is not going to be reverted on master, add the backport-blocked label
  • If the PR is going to be reverted on master, add the dont-land-on label to both the original and the revert PRs.

async_hooks change causes Node process to crash #31783

Introduced in https://github.com/nodejs/node/pull/30965. That bug was only reported to us after it landed in v12.16.0 and is now fixed.

http response listener throwing does not result in emit of uncaughtException #31796

Introduced in https://github.com/nodejs/node/pull/30236. That bug was only reported to us after it landed in v12.16.0 and is now fixed.

New enumerable and nonwritable field on EventEmitter caused issues #30932

Introduced in https://github.com/nodejs/node/pull/30932. That was only reported to us after it landed in v12.16.0.

It is not obvious to me what we could have done better about the last three issues. They only affect specific cases that we did not test for and were not detected by people who use or run their tests on v13.x Current.

created time in 9 days

pull request commentnodejs/node

src: unregister Isolate with platform before disposing

IIUC, this is no longer removed from v12.x

addaleax

comment created time in 9 days

issue commentnodejs/node

class name not being inherited in an anonymous class since 12.16.0

Could you check what spidermonkey and jsc do?

YoannMa

comment created time in 9 days

push eventtargos/dot-files

Michaël Zasso

commit sha db50bfe4a2bdb9fd1bda6e1c8473abfe55d62549

alias git https to ssh

view details

Michaël Zasso

commit sha 3235949c895d894323fda9aff55061f26d7d64a5

add nbd-lts

view details

push time in 9 days

issue commentnodejs/node

conditional exports show an unexpected warning message, even though no longer behind flag

The entire ECMAScript Modules implementation is experimental and is marked as such in the documentation. The fact that we removed the flag doesn't mean the API is stable yet

FredKSchott

comment created time in 10 days

pull request commentnodejs/node

timers: captureRejections for timers

@Flarna I tend to agree with you and someone made me realize today that it's actually the same with the event emitter captures. Only rejecting async handlers can be caught, not throwing sync handlers.

jasnell

comment created time in 10 days

pull request commentnodejs/node

http: end with data should emit write after end error

Looks like it landed in c776a37791007e0d570355b731647e58ea5885be instead

ronag

comment created time in 11 days

Pull request review commentnodejs/node

async-hooks: introduce async-storage API

 class AsyncResource {   } } +const locals = [];+const asyncContextHook = createHook({+  init(asyncId, type, triggerAsyncId, resource) {+    for (let i = 0; i < locals.length; ++i) {+      locals[i]._propagate(resource, executionAsyncResource());+    }+  }+});++class AsyncLocalStorage {+  constructor() {+    this.kResourceStore = Symbol('kResourceStore');+  }++  /**+   * Propagate the context from a parent resource to a child one.+   */+  _propagate(resource, triggerResource) {+    const store = triggerResource[this.kResourceStore];+    if (store) {+      resource[this.kResourceStore] = store;

Do you see any issue we could meet with the Symbol approach?

No

vdeturckheim

comment created time in 11 days

Pull request review commentnodejs/node-gyp

gyp: sync code base with nodejs repo

 def _InstallableTargetInstallPath(self):     """Returns the location of the final output for an installable target."""     # Xcode puts shared_library results into PRODUCT_DIR, and some gyp files     # rely on this. Emulate this behavior for mac.--    # XXX(TooTallNate): disabling this code since we don't want this behavior...

I think this is not a blocker anymore.

targos

comment created time in 11 days

issue commentnodejs/node

Clear the internal require `statCache` on an unsuccessful module load?

Does require.resolve have the same restriction? If not, it can be used to check if the module is there before trying to require it

benjamingr

comment created time in 12 days

issue commentnodejs/TSC

Review meeting date times ?

Thursdays work for me. If we do multiple days we'll need multiple spreadsheets

mhdawson

comment created time in 12 days

Pull request review commentnodejs/node

async-hooks: introduce async-storage API

 const {   NumberIsSafeInteger,   ReflectApply,   Symbol,+  Map,

Please keep the imports in alphabetical order.

vdeturckheim

comment created time in 12 days

Pull request review commentnodejs/node

async-hooks: introduce async-storage API

 class AsyncResource {   } } +const locals = [];+const asyncContextHook = createHook({+  init(asyncId, type, triggerAsyncId, resource) {+    for (let i = 0; i < locals.length; ++i) {+      locals[i]._propagate(resource, executionAsyncResource());+    }+  }+});++class AsyncLocalStorage {+  constructor() {+    this.kResourceStore = Symbol('kResourceStore');+  }++  /**+   * Propagate the context from a parent resource to a child one.+   */+  _propagate(resource, triggerResource) {+    const store = triggerResource[this.kResourceStore];+    if (store) {+      resource[this.kResourceStore] = store;
      resource[this.kResourceStore] = store;

I wonder if we shouldn't use a Map or WeakMap with resource as the key instead of putting the store on the resource itself?

vdeturckheim

comment created time in 12 days

Pull request review commentnodejs/node

async-hooks: introduce async-storage API

 for (let i = 0; i < 10; i++) { } ``` +## Class: AsyncLocalStorage+<!-- YAML+added: REPLACEME+-->++This class is used to create asynchronous state within callbacks and promise+chains. It allows storing data throughout the lifetime of a web request+or any other asynchronous duration. It is similar to thread local storage+in other languages.++The following example builds a logger that will always know the current HTTP+request and uses it to display enhanced logs without needing to explicitly+provide the current HTTP request to it.++```js+const { AsyncLocalStorage } = require('async_hooks');+const http = require('http');++const kReq = 'CURRENT_REQUEST';+const asyncLocalStorage = new AsyncLocalStorage();++function log(...args) {+  const store = asyncLocalStorage.getStore();+  // Make sure the store exists and it contains a request.+  if (store && store.has(kReq)) {+    const req = store.get(kReq);+    // Prints `GET /items ERR could not do something+    console.log(req.method, req.url, ...args);+  } else {+    console.log(...args);+  }+}++http.createServer((request, response) => {+  asyncLocalStorage.run(() => {+    const store = asyncLocalStorage.getStore();+    store.set(kReq, request);+    someAsyncOperation((err, result) => {+      if (err) {+        log('ERR', err.message);+      }+    });+  });+})+.listen(8080);+```++When having multiple instance of `AsyncLocalStorage`, they are independent+from each others. It is safe to instantiate this class multiple times.++### new AsyncLocalStorage()+<!-- YAML+added: REPLACEME+-->++* Returns: {Object}++Creates a new instance of `AsyncContext`. Storage is only provided within a+`run` or a `runSyncAndReturn` method call.++### asyncLocalStorage.getStore()+<!-- YAML+added: REPLACEME+-->++* Returns: {Map}++This methods returns the current store.+If this method is called  outside of an asynchronous context initialized by+calling `asyncLocalStorage.run` or `asyncLocalStorage.runAndReturn`, it will+return `undefined`.++### asyncLocalStorage.run(callback\[, ...args\])+<!-- YAML+added: REPLACEME+-->++* `callback` {Function}+* `...args` {any}++Calling `asyncLocalStorage.run(callback)` will create a new asynchronous+context.+Within the callback function and the asynchronous operations from the callback,+`asyncLocalStorage.getStore()` will return an instance of `Map` known as+"the store". This store will be persistent through the following+asynchronous calls.++The callback will be ran asynchronously.++If an error is thrown by the callback function. It won't be caught by a+a `try/catch` block as the callback is ran in a new asynchronous resource.+Also, the stacktrace will be impacted by the asynchronous call.++Optionally, arguments can be passed to the function, they will be passed to+the callback function.++#### example+```js+asyncLocalStorage.run(() => {+  asyncLocalStorage.getStore(); // Will return a Map+  someAsyncOperation(() => {+    asyncLocalStorage.getStore(); // Will return the same Map+  });+});+asyncLocalStorage.getStore(); // Will return undefined+```++### asyncLocalStorage.exit(callback\[, ...args\])+<!-- YAML+added: REPLACEME+-->++* `callback` {Function}+* `...args` {any}++Calling `asyncLocalStorage.exit(callback)` will create a new asynchronous+context.+Within the callback function and the asynchronous operations from the callback,+`asyncLocalStorage.getStore()` will return `undefined`.+The callback will be ran asynchronously.++If an error is thrown by the callback function. It won't be caught by a+a `try/catch` block as the callback is ran in a new asynchronous resource.+Also, the stacktrace will be impacted by the asynchronous call.++Optionally, arguments can be passed to the function, they will be passed to+the callback function.++#### example+```js+asyncLocalStorage.run(() => {+  asyncLocalStorage.getStore(); // Will return a Map+  asyncLocalStorage.exit(() => {+    asyncLocalStorage.getStore(); // Will return undefined+  });+  asyncLocalStorage.getStore(); // Will return the same Map+});+```++### asyncLocalStorage.runSyncAndReturn(callback\[, ...args\])+<!-- YAML+added: REPLACEME+-->++* `callback` {Function}+* `...args` {any}++This methods runs a function synchronously within a context and return its+return value. The store is not accessible outside of the callback function or+the asynchronous operations created within the callback.++If the callback function throws an error, it will be thrown by+`runSyncAndReturn` too. The stacktrace will not be impacted by this call and+the context will be excited.++Optionally, arguments can be passed to the function, they will be passed to+the callback function.++#### example+```js+try {+  asyncLocalStorage.runSyncAndReturn(() => {+    asyncLocalStorage.getStore(); // Will return a Map+    throw new Error();+  });+} catch (e) {+  asyncLocalStorage.getStore(); // Will return undefined+  // The error will be caught here+}+```++### asyncLocalStorage.exitSyncAndReturn(callback\[, ...args\])+<!-- YAML+added: REPLACEME+-->++* `callback` {Function}+* `...args` {any}++This methods runs a function synchronously outside of a context and return its+return value. The store is not accessible within the callback function or+the asynchronous operations created within the callback.++If the callback function throws an error, it will be thrown by+`exitSyncAndReturn` too. The stacktrace will not be impacted by this call and+the context will be re-entered.++Optionally, arguments can be passed to the function, they will be passed to+the callback function.++#### example+```js+// Within a call to run or runAsyncAndReturn+try {+  asyncLocalStorage.getStore(); // Will return a Map
  asyncLocalStorage.getStore(); // Returns a Map
vdeturckheim

comment created time in 12 days

Pull request review commentnodejs/node

async-hooks: introduce async-storage API

 class AsyncResource {   } } +const locals = [];

A Set seems more appropriate than an array here. Is it like this for performance reasons?

vdeturckheim

comment created time in 12 days

Pull request review commentnodejs/node

async-hooks: introduce async-storage API

 module.exports = {   executionAsyncResource,   // Embedder API   AsyncResource,+  AsyncLocalStorage,

I don't know what "Embedder API" means here, but I think AsyncLocalStorage is public API and can be the first in the exports (alphabetical order).

vdeturckheim

comment created time in 12 days

Pull request review commentnodejs/node

async-hooks: introduce async-storage API

 class AsyncResource {   } } +const locals = [];+const asyncContextHook = createHook({+  init(asyncId, type, triggerAsyncId, resource) {+    for (let i = 0; i < locals.length; ++i) {+      locals[i]._propagate(resource, executionAsyncResource());+    }+  }+});++class AsyncLocalStorage {+  constructor() {+    this.kResourceStore = Symbol('kResourceStore');+  }++  /**+   * Propagate the context from a parent resource to a child one.+   */+  _propagate(resource, triggerResource) {+    const store = triggerResource[this.kResourceStore];+    if (store) {+      resource[this.kResourceStore] = store;+    }+  }++  _enter() {+    asyncContextHook.enable();+    if (!locals.includes(this)) {+      locals.push(this);+    }+    const resource = executionAsyncResource();+    const store = new Map();+    resource[this.kResourceStore] = store;+    return store;+  }++  _exit() {+    const resource = executionAsyncResource();+    if (resource) {+      delete resource[this.kResourceStore];+    }+  }++  runSyncAndReturn(callback, ...args) {+    this._enter();+    try {+      return callback(...args);+    } finally {+      this._exit();+    }+  }++  exitSyncAndReturn(callback, ...args) {+    const resource = executionAsyncResource();+    if (!resource) {+      return callback(...args);+    }+    const store = resource[this.kResourceStore];+    delete resource[this.kResourceStore];+    try {+      return callback(...args);+    } finally {+      resource[this.kResourceStore] = store;+    }+  }++  /**+   * get the current store, i.e. the unique map associated with current
   * Get the current store, i.e. the unique map associated with current
vdeturckheim

comment created time in 12 days

Pull request review commentnodejs/node

async-hooks: introduce async-storage API

 for (let i = 0; i < 10; i++) { } ``` +## Class: AsyncLocalStorage+<!-- YAML+added: REPLACEME+-->++This class is used to create asynchronous state within callbacks and promise+chains. It allows storing data throughout the lifetime of a web request+or any other asynchronous duration. It is similar to thread local storage+in other languages.++The following example builds a logger that will always know the current HTTP+request and uses it to display enhanced logs without needing to explicitly+provide the current HTTP request to it.++```js+const { AsyncLocalStorage } = require('async_hooks');+const http = require('http');++const kReq = 'CURRENT_REQUEST';+const asyncLocalStorage = new AsyncLocalStorage();++function log(...args) {+  const store = asyncLocalStorage.getStore();+  // Make sure the store exists and it contains a request.+  if (store && store.has(kReq)) {+    const req = store.get(kReq);+    // Prints `GET /items ERR could not do something+    console.log(req.method, req.url, ...args);+  } else {+    console.log(...args);+  }+}++http.createServer((request, response) => {+  asyncLocalStorage.run(() => {+    const store = asyncLocalStorage.getStore();+    store.set(kReq, request);+    someAsyncOperation((err, result) => {+      if (err) {+        log('ERR', err.message);+      }+    });+  });+})+.listen(8080);+```++When having multiple instance of `AsyncLocalStorage`, they are independent+from each others. It is safe to instantiate this class multiple times.++### new AsyncLocalStorage()+<!-- YAML+added: REPLACEME+-->++* Returns: {Object}++Creates a new instance of `AsyncContext`. Storage is only provided within a+`run` or a `runSyncAndReturn` method call.++### asyncLocalStorage.getStore()+<!-- YAML+added: REPLACEME+-->++* Returns: {Map}++This methods returns the current store.+If this method is called  outside of an asynchronous context initialized by+calling `asyncLocalStorage.run` or `asyncLocalStorage.runAndReturn`, it will+return `undefined`.++### asyncLocalStorage.run(callback\[, ...args\])+<!-- YAML+added: REPLACEME+-->++* `callback` {Function}+* `...args` {any}++Calling `asyncLocalStorage.run(callback)` will create a new asynchronous+context.+Within the callback function and the asynchronous operations from the callback,+`asyncLocalStorage.getStore()` will return an instance of `Map` known as+"the store". This store will be persistent through the following+asynchronous calls.++The callback will be ran asynchronously.++If an error is thrown by the callback function. It won't be caught by a+a `try/catch` block as the callback is ran in a new asynchronous resource.+Also, the stacktrace will be impacted by the asynchronous call.++Optionally, arguments can be passed to the function, they will be passed to+the callback function.++#### example+```js+asyncLocalStorage.run(() => {+  asyncLocalStorage.getStore(); // Will return a Map+  someAsyncOperation(() => {+    asyncLocalStorage.getStore(); // Will return the same Map+  });+});+asyncLocalStorage.getStore(); // Will return undefined+```++### asyncLocalStorage.exit(callback\[, ...args\])+<!-- YAML+added: REPLACEME+-->++* `callback` {Function}+* `...args` {any}++Calling `asyncLocalStorage.exit(callback)` will create a new asynchronous+context.+Within the callback function and the asynchronous operations from the callback,+`asyncLocalStorage.getStore()` will return `undefined`.+The callback will be ran asynchronously.++If an error is thrown by the callback function. It won't be caught by a+a `try/catch` block as the callback is ran in a new asynchronous resource.+Also, the stacktrace will be impacted by the asynchronous call.++Optionally, arguments can be passed to the function, they will be passed to+the callback function.++#### example+```js+asyncLocalStorage.run(() => {+  asyncLocalStorage.getStore(); // Will return a Map+  asyncLocalStorage.exit(() => {+    asyncLocalStorage.getStore(); // Will return undefined+  });+  asyncLocalStorage.getStore(); // Will return the same Map+});+```++### asyncLocalStorage.runSyncAndReturn(callback\[, ...args\])+<!-- YAML+added: REPLACEME+-->++* `callback` {Function}+* `...args` {any}++This methods runs a function synchronously within a context and return its+return value. The store is not accessible outside of the callback function or+the asynchronous operations created within the callback.++If the callback function throws an error, it will be thrown by+`runSyncAndReturn` too. The stacktrace will not be impacted by this call and+the context will be excited.++Optionally, arguments can be passed to the function, they will be passed to+the callback function.++#### example+```js+try {+  asyncLocalStorage.runSyncAndReturn(() => {+    asyncLocalStorage.getStore(); // Will return a Map+    throw new Error();+  });+} catch (e) {+  asyncLocalStorage.getStore(); // Will return undefined+  // The error will be caught here+}+```++### asyncLocalStorage.exitSyncAndReturn(callback\[, ...args\])+<!-- YAML+added: REPLACEME+-->++* `callback` {Function}+* `...args` {any}++This methods runs a function synchronously outside of a context and return its+return value. The store is not accessible within the callback function or+the asynchronous operations created within the callback.++If the callback function throws an error, it will be thrown by+`exitSyncAndReturn` too. The stacktrace will not be impacted by this call and+the context will be re-entered.++Optionally, arguments can be passed to the function, they will be passed to+the callback function.++#### example+```js+// Within a call to run or runAsyncAndReturn+try {+  asyncLocalStorage.getStore(); // Will return a Map+  asyncLocalStorage.exitSyncAndReturn(() => {+    asyncLocalStorage.getStore(); // Will return undefined+    throw new Error();+  });+} catch (e) {+  asyncLocalStorage.getStore(); // Will return a Map+  // The error will be caught here+}+```++### Choosing between `run` and `runAsyncAndReturn`++#### When to choose `run`+`run` is asynchronous. It is called with a callback function that+runs within a new asynchronous call. This is the most explicit behavior as+everything that is executed within the callback of `run` (including further+asynchronous operations) will have access to the store.++If an instance of AsyncLocalStorage is used for error management (for instance+with `process.setUncaughtExceptionCaptureCallback`). Only the exceptions thrown+in the scope of the callback function will be associated with the context.++This method the safest to call as it provides strong scoping and consistent+behavior.++It can't be promisified using `util.promisify`. If needed, the `Promise`
It cannot be promisified using `util.promisify`. If needed, the `Promise`
vdeturckheim

comment created time in 12 days

Pull request review commentnodejs/node

async-hooks: introduce async-storage API

 for (let i = 0; i < 10; i++) { } ``` +## Class: AsyncLocalStorage+<!-- YAML+added: REPLACEME+-->++This class is used to create asynchronous state within callbacks and promise+chains. It allows storing data throughout the lifetime of a web request+or any other asynchronous duration. It is similar to thread local storage+in other languages.++The following example builds a logger that will always know the current HTTP+request and uses it to display enhanced logs without needing to explicitly+provide the current HTTP request to it.++```js+const { AsyncLocalStorage } = require('async_hooks');+const http = require('http');++const kReq = 'CURRENT_REQUEST';+const asyncLocalStorage = new AsyncLocalStorage();++function log(...args) {+  const store = asyncLocalStorage.getStore();+  // Make sure the store exists and it contains a request.+  if (store && store.has(kReq)) {+    const req = store.get(kReq);+    // Prints `GET /items ERR could not do something+    console.log(req.method, req.url, ...args);+  } else {+    console.log(...args);+  }+}++http.createServer((request, response) => {+  asyncLocalStorage.run(() => {+    const store = asyncLocalStorage.getStore();+    store.set(kReq, request);+    someAsyncOperation((err, result) => {+      if (err) {+        log('ERR', err.message);+      }+    });+  });+})+.listen(8080);+```++When having multiple instance of `AsyncLocalStorage`, they are independent+from each others. It is safe to instantiate this class multiple times.++### new AsyncLocalStorage()+<!-- YAML+added: REPLACEME+-->++* Returns: {Object}++Creates a new instance of `AsyncContext`. Storage is only provided within a+`run` or a `runSyncAndReturn` method call.++### asyncLocalStorage.getStore()+<!-- YAML+added: REPLACEME+-->++* Returns: {Map}++This methods returns the current store.+If this method is called  outside of an asynchronous context initialized by+calling `asyncLocalStorage.run` or `asyncLocalStorage.runAndReturn`, it will+return `undefined`.++### asyncLocalStorage.run(callback\[, ...args\])+<!-- YAML+added: REPLACEME+-->++* `callback` {Function}+* `...args` {any}++Calling `asyncLocalStorage.run(callback)` will create a new asynchronous+context.+Within the callback function and the asynchronous operations from the callback,+`asyncLocalStorage.getStore()` will return an instance of `Map` known as+"the store". This store will be persistent through the following+asynchronous calls.++The callback will be ran asynchronously.++If an error is thrown by the callback function. It won't be caught by a+a `try/catch` block as the callback is ran in a new asynchronous resource.+Also, the stacktrace will be impacted by the asynchronous call.++Optionally, arguments can be passed to the function, they will be passed to+the callback function.++#### example+```js+asyncLocalStorage.run(() => {+  asyncLocalStorage.getStore(); // Will return a Map+  someAsyncOperation(() => {+    asyncLocalStorage.getStore(); // Will return the same Map+  });+});+asyncLocalStorage.getStore(); // Will return undefined+```++### asyncLocalStorage.exit(callback\[, ...args\])+<!-- YAML+added: REPLACEME+-->++* `callback` {Function}+* `...args` {any}++Calling `asyncLocalStorage.exit(callback)` will create a new asynchronous+context.+Within the callback function and the asynchronous operations from the callback,+`asyncLocalStorage.getStore()` will return `undefined`.+The callback will be ran asynchronously.++If an error is thrown by the callback function. It won't be caught by a+a `try/catch` block as the callback is ran in a new asynchronous resource.+Also, the stacktrace will be impacted by the asynchronous call.++Optionally, arguments can be passed to the function, they will be passed to+the callback function.++#### example+```js+asyncLocalStorage.run(() => {+  asyncLocalStorage.getStore(); // Will return a Map+  asyncLocalStorage.exit(() => {+    asyncLocalStorage.getStore(); // Will return undefined+  });+  asyncLocalStorage.getStore(); // Will return the same Map+});+```++### asyncLocalStorage.runSyncAndReturn(callback\[, ...args\])+<!-- YAML+added: REPLACEME+-->++* `callback` {Function}+* `...args` {any}++This methods runs a function synchronously within a context and return its+return value. The store is not accessible outside of the callback function or+the asynchronous operations created within the callback.++If the callback function throws an error, it will be thrown by+`runSyncAndReturn` too. The stacktrace will not be impacted by this call and+the context will be excited.++Optionally, arguments can be passed to the function, they will be passed to+the callback function.++#### example+```js+try {+  asyncLocalStorage.runSyncAndReturn(() => {+    asyncLocalStorage.getStore(); // Will return a Map+    throw new Error();+  });+} catch (e) {+  asyncLocalStorage.getStore(); // Will return undefined+  // The error will be caught here+}+```++### asyncLocalStorage.exitSyncAndReturn(callback\[, ...args\])+<!-- YAML+added: REPLACEME+-->++* `callback` {Function}+* `...args` {any}++This methods runs a function synchronously outside of a context and return its+return value. The store is not accessible within the callback function or+the asynchronous operations created within the callback.++If the callback function throws an error, it will be thrown by+`exitSyncAndReturn` too. The stacktrace will not be impacted by this call and+the context will be re-entered.++Optionally, arguments can be passed to the function, they will be passed to+the callback function.++#### example+```js+// Within a call to run or runAsyncAndReturn+try {+  asyncLocalStorage.getStore(); // Will return a Map+  asyncLocalStorage.exitSyncAndReturn(() => {+    asyncLocalStorage.getStore(); // Will return undefined+    throw new Error();+  });+} catch (e) {+  asyncLocalStorage.getStore(); // Will return a Map+  // The error will be caught here+}+```++### Choosing between `run` and `runAsyncAndReturn`++#### When to choose `run`+`run` is asynchronous. It is called with a callback function that+runs within a new asynchronous call. This is the most explicit behavior as+everything that is executed within the callback of `run` (including further+asynchronous operations) will have access to the store.++If an instance of AsyncLocalStorage is used for error management (for instance+with `process.setUncaughtExceptionCaptureCallback`). Only the exceptions thrown+in the scope of the callback function will be associated with the context.++This method the safest to call as it provides strong scoping and consistent+behavior.++It can't be promisified using `util.promisify`. If needed, the `Promise`+constructor can be used:++```js+new Promise((resolve, reject) => {+  asyncLocalStorage.run(() => {+    someFunction((err, result) => {+      if (err) {+        return reject(err);+      }+      return resolve(result);+    });+  });+});+```++#### When to choose `runSyncAndReturn`+`runSyncAndReturn` is synchronous. The callback function will be executed+synchronously and it's return value will be returned by `runAndReturn`.+The store will only be accessible from within the callback+function and the asynchronous operations created within this scope.+If the callback throws an error, `runAndReturn` will throw it and it will not
If the callback throws an error, `runSyncAndReturn` will throw it and it will not
vdeturckheim

comment created time in 12 days

Pull request review commentnodejs/node

async-hooks: introduce async-storage API

 for (let i = 0; i < 10; i++) { } ``` +## Class: AsyncLocalStorage+<!-- YAML+added: REPLACEME+-->++This class is used to create asynchronous state within callbacks and promise+chains. It allows storing data throughout the lifetime of a web request+or any other asynchronous duration. It is similar to thread local storage+in other languages.++The following example builds a logger that will always know the current HTTP+request and uses it to display enhanced logs without needing to explicitly+provide the current HTTP request to it.++```js+const { AsyncLocalStorage } = require('async_hooks');+const http = require('http');++const kReq = 'CURRENT_REQUEST';+const asyncLocalStorage = new AsyncLocalStorage();++function log(...args) {+  const store = asyncLocalStorage.getStore();+  // Make sure the store exists and it contains a request.+  if (store && store.has(kReq)) {+    const req = store.get(kReq);+    // Prints `GET /items ERR could not do something+    console.log(req.method, req.url, ...args);+  } else {+    console.log(...args);+  }+}++http.createServer((request, response) => {+  asyncLocalStorage.run(() => {+    const store = asyncLocalStorage.getStore();+    store.set(kReq, request);+    someAsyncOperation((err, result) => {+      if (err) {+        log('ERR', err.message);+      }+    });+  });+})+.listen(8080);+```++When having multiple instance of `AsyncLocalStorage`, they are independent+from each others. It is safe to instantiate this class multiple times.++### new AsyncLocalStorage()+<!-- YAML+added: REPLACEME+-->++* Returns: {Object}++Creates a new instance of `AsyncContext`. Storage is only provided within a+`run` or a `runSyncAndReturn` method call.++### asyncLocalStorage.getStore()+<!-- YAML+added: REPLACEME+-->++* Returns: {Map}++This methods returns the current store.+If this method is called  outside of an asynchronous context initialized by+calling `asyncLocalStorage.run` or `asyncLocalStorage.runAndReturn`, it will+return `undefined`.++### asyncLocalStorage.run(callback\[, ...args\])+<!-- YAML+added: REPLACEME+-->++* `callback` {Function}+* `...args` {any}++Calling `asyncLocalStorage.run(callback)` will create a new asynchronous+context.+Within the callback function and the asynchronous operations from the callback,+`asyncLocalStorage.getStore()` will return an instance of `Map` known as+"the store". This store will be persistent through the following+asynchronous calls.++The callback will be ran asynchronously.++If an error is thrown by the callback function. It won't be caught by a+a `try/catch` block as the callback is ran in a new asynchronous resource.+Also, the stacktrace will be impacted by the asynchronous call.++Optionally, arguments can be passed to the function, they will be passed to+the callback function.++#### example+```js+asyncLocalStorage.run(() => {+  asyncLocalStorage.getStore(); // Will return a Map+  someAsyncOperation(() => {+    asyncLocalStorage.getStore(); // Will return the same Map+  });+});+asyncLocalStorage.getStore(); // Will return undefined+```++### asyncLocalStorage.exit(callback\[, ...args\])+<!-- YAML+added: REPLACEME+-->++* `callback` {Function}+* `...args` {any}++Calling `asyncLocalStorage.exit(callback)` will create a new asynchronous+context.+Within the callback function and the asynchronous operations from the callback,+`asyncLocalStorage.getStore()` will return `undefined`.+The callback will be ran asynchronously.++If an error is thrown by the callback function. It won't be caught by a+a `try/catch` block as the callback is ran in a new asynchronous resource.+Also, the stacktrace will be impacted by the asynchronous call.++Optionally, arguments can be passed to the function, they will be passed to+the callback function.++#### example+```js+asyncLocalStorage.run(() => {+  asyncLocalStorage.getStore(); // Will return a Map+  asyncLocalStorage.exit(() => {+    asyncLocalStorage.getStore(); // Will return undefined+  });+  asyncLocalStorage.getStore(); // Will return the same Map+});+```++### asyncLocalStorage.runSyncAndReturn(callback\[, ...args\])+<!-- YAML+added: REPLACEME+-->++* `callback` {Function}+* `...args` {any}++This methods runs a function synchronously within a context and return its+return value. The store is not accessible outside of the callback function or+the asynchronous operations created within the callback.++If the callback function throws an error, it will be thrown by+`runSyncAndReturn` too. The stacktrace will not be impacted by this call and+the context will be excited.++Optionally, arguments can be passed to the function, they will be passed to+the callback function.++#### example+```js+try {+  asyncLocalStorage.runSyncAndReturn(() => {+    asyncLocalStorage.getStore(); // Will return a Map+    throw new Error();+  });+} catch (e) {+  asyncLocalStorage.getStore(); // Will return undefined+  // The error will be caught here+}+```++### asyncLocalStorage.exitSyncAndReturn(callback\[, ...args\])+<!-- YAML+added: REPLACEME+-->++* `callback` {Function}+* `...args` {any}++This methods runs a function synchronously outside of a context and return its+return value. The store is not accessible within the callback function or+the asynchronous operations created within the callback.++If the callback function throws an error, it will be thrown by+`exitSyncAndReturn` too. The stacktrace will not be impacted by this call and+the context will be re-entered.++Optionally, arguments can be passed to the function, they will be passed to+the callback function.++#### example+```js+// Within a call to run or runAsyncAndReturn+try {+  asyncLocalStorage.getStore(); // Will return a Map+  asyncLocalStorage.exitSyncAndReturn(() => {+    asyncLocalStorage.getStore(); // Will return undefined
    asyncLocalStorage.getStore(); // Returns undefined
vdeturckheim

comment created time in 12 days

Pull request review commentnodejs/node

async-hooks: introduce async-storage API

 for (let i = 0; i < 10; i++) { } ``` +## Class: AsyncLocalStorage+<!-- YAML+added: REPLACEME+-->++This class is used to create asynchronous state within callbacks and promise+chains. It allows storing data throughout the lifetime of a web request+or any other asynchronous duration. It is similar to thread local storage+in other languages.++The following example builds a logger that will always know the current HTTP+request and uses it to display enhanced logs without needing to explicitly+provide the current HTTP request to it.++```js+const { AsyncLocalStorage } = require('async_hooks');+const http = require('http');++const kReq = 'CURRENT_REQUEST';+const asyncLocalStorage = new AsyncLocalStorage();++function log(...args) {+  const store = asyncLocalStorage.getStore();+  // Make sure the store exists and it contains a request.+  if (store && store.has(kReq)) {+    const req = store.get(kReq);+    // Prints `GET /items ERR could not do something+    console.log(req.method, req.url, ...args);+  } else {+    console.log(...args);+  }+}++http.createServer((request, response) => {+  asyncLocalStorage.run(() => {+    const store = asyncLocalStorage.getStore();+    store.set(kReq, request);+    someAsyncOperation((err, result) => {+      if (err) {+        log('ERR', err.message);+      }+    });+  });+})+.listen(8080);+```++When having multiple instance of `AsyncLocalStorage`, they are independent+from each others. It is safe to instantiate this class multiple times.++### new AsyncLocalStorage()+<!-- YAML+added: REPLACEME+-->++* Returns: {Object}++Creates a new instance of `AsyncContext`. Storage is only provided within a+`run` or a `runSyncAndReturn` method call.++### asyncLocalStorage.getStore()+<!-- YAML+added: REPLACEME+-->++* Returns: {Map}++This methods returns the current store.+If this method is called  outside of an asynchronous context initialized by+calling `asyncLocalStorage.run` or `asyncLocalStorage.runAndReturn`, it will+return `undefined`.++### asyncLocalStorage.run(callback\[, ...args\])+<!-- YAML+added: REPLACEME+-->++* `callback` {Function}+* `...args` {any}++Calling `asyncLocalStorage.run(callback)` will create a new asynchronous+context.+Within the callback function and the asynchronous operations from the callback,+`asyncLocalStorage.getStore()` will return an instance of `Map` known as+"the store". This store will be persistent through the following+asynchronous calls.++The callback will be ran asynchronously.++If an error is thrown by the callback function. It won't be caught by a+a `try/catch` block as the callback is ran in a new asynchronous resource.+Also, the stacktrace will be impacted by the asynchronous call.++Optionally, arguments can be passed to the function, they will be passed to+the callback function.++#### example+```js+asyncLocalStorage.run(() => {+  asyncLocalStorage.getStore(); // Will return a Map+  someAsyncOperation(() => {+    asyncLocalStorage.getStore(); // Will return the same Map+  });+});+asyncLocalStorage.getStore(); // Will return undefined+```++### asyncLocalStorage.exit(callback\[, ...args\])+<!-- YAML+added: REPLACEME+-->++* `callback` {Function}+* `...args` {any}++Calling `asyncLocalStorage.exit(callback)` will create a new asynchronous+context.+Within the callback function and the asynchronous operations from the callback,+`asyncLocalStorage.getStore()` will return `undefined`.+The callback will be ran asynchronously.++If an error is thrown by the callback function. It won't be caught by a+a `try/catch` block as the callback is ran in a new asynchronous resource.+Also, the stacktrace will be impacted by the asynchronous call.++Optionally, arguments can be passed to the function, they will be passed to+the callback function.++#### example+```js+asyncLocalStorage.run(() => {+  asyncLocalStorage.getStore(); // Will return a Map+  asyncLocalStorage.exit(() => {+    asyncLocalStorage.getStore(); // Will return undefined+  });+  asyncLocalStorage.getStore(); // Will return the same Map+});+```++### asyncLocalStorage.runSyncAndReturn(callback\[, ...args\])+<!-- YAML+added: REPLACEME+-->++* `callback` {Function}+* `...args` {any}++This methods runs a function synchronously within a context and return its+return value. The store is not accessible outside of the callback function or+the asynchronous operations created within the callback.++If the callback function throws an error, it will be thrown by+`runSyncAndReturn` too. The stacktrace will not be impacted by this call and+the context will be excited.++Optionally, arguments can be passed to the function, they will be passed to+the callback function.++#### example+```js+try {+  asyncLocalStorage.runSyncAndReturn(() => {+    asyncLocalStorage.getStore(); // Will return a Map+    throw new Error();+  });+} catch (e) {+  asyncLocalStorage.getStore(); // Will return undefined+  // The error will be caught here+}+```++### asyncLocalStorage.exitSyncAndReturn(callback\[, ...args\])+<!-- YAML+added: REPLACEME+-->++* `callback` {Function}+* `...args` {any}++This methods runs a function synchronously outside of a context and return its+return value. The store is not accessible within the callback function or+the asynchronous operations created within the callback.++If the callback function throws an error, it will be thrown by+`exitSyncAndReturn` too. The stacktrace will not be impacted by this call and+the context will be re-entered.++Optionally, arguments can be passed to the function, they will be passed to+the callback function.++#### example+```js+// Within a call to run or runAsyncAndReturn+try {+  asyncLocalStorage.getStore(); // Will return a Map+  asyncLocalStorage.exitSyncAndReturn(() => {+    asyncLocalStorage.getStore(); // Will return undefined+    throw new Error();+  });+} catch (e) {+  asyncLocalStorage.getStore(); // Will return a Map
  asyncLocalStorage.getStore(); // Returns a Map
vdeturckheim

comment created time in 12 days

Pull request review commentnodejs/node

async-hooks: introduce async-storage API

 for (let i = 0; i < 10; i++) { } ``` +## Class: AsyncLocalStorage+<!-- YAML+added: REPLACEME+-->++This class is used to create asynchronous state within callbacks and promise+chains. It allows storing data throughout the lifetime of a web request+or any other asynchronous duration. It is similar to thread local storage+in other languages.++The following example builds a logger that will always know the current HTTP+request and uses it to display enhanced logs without needing to explicitly+provide the current HTTP request to it.++```js+const { AsyncLocalStorage } = require('async_hooks');+const http = require('http');++const kReq = 'CURRENT_REQUEST';+const asyncLocalStorage = new AsyncLocalStorage();++function log(...args) {+  const store = asyncLocalStorage.getStore();+  // Make sure the store exists and it contains a request.+  if (store && store.has(kReq)) {+    const req = store.get(kReq);+    // Prints `GET /items ERR could not do something+    console.log(req.method, req.url, ...args);+  } else {+    console.log(...args);+  }+}++http.createServer((request, response) => {+  asyncLocalStorage.run(() => {+    const store = asyncLocalStorage.getStore();+    store.set(kReq, request);+    someAsyncOperation((err, result) => {+      if (err) {+        log('ERR', err.message);+      }+    });+  });+})+.listen(8080);+```++When having multiple instance of `AsyncLocalStorage`, they are independent+from each others. It is safe to instantiate this class multiple times.++### new AsyncLocalStorage()+<!-- YAML+added: REPLACEME+-->++* Returns: {Object}++Creates a new instance of `AsyncContext`. Storage is only provided within a+`run` or a `runSyncAndReturn` method call.++### asyncLocalStorage.getStore()+<!-- YAML+added: REPLACEME+-->++* Returns: {Map}++This methods returns the current store.+If this method is called  outside of an asynchronous context initialized by+calling `asyncLocalStorage.run` or `asyncLocalStorage.runAndReturn`, it will+return `undefined`.++### asyncLocalStorage.run(callback\[, ...args\])+<!-- YAML+added: REPLACEME+-->++* `callback` {Function}+* `...args` {any}++Calling `asyncLocalStorage.run(callback)` will create a new asynchronous+context.+Within the callback function and the asynchronous operations from the callback,+`asyncLocalStorage.getStore()` will return an instance of `Map` known as+"the store". This store will be persistent through the following+asynchronous calls.++The callback will be ran asynchronously.++If an error is thrown by the callback function. It won't be caught by a+a `try/catch` block as the callback is ran in a new asynchronous resource.+Also, the stacktrace will be impacted by the asynchronous call.++Optionally, arguments can be passed to the function, they will be passed to+the callback function.++#### example
Example:

vdeturckheim

comment created time in 12 days

Pull request review commentnodejs/node

async-hooks: introduce async-storage API

 for (let i = 0; i < 10; i++) { } ``` +## Class: AsyncLocalStorage+<!-- YAML+added: REPLACEME+-->++This class is used to create asynchronous state within callbacks and promise+chains. It allows storing data throughout the lifetime of a web request+or any other asynchronous duration. It is similar to thread local storage+in other languages.++The following example builds a logger that will always know the current HTTP+request and uses it to display enhanced logs without needing to explicitly+provide the current HTTP request to it.++```js+const { AsyncLocalStorage } = require('async_hooks');+const http = require('http');++const kReq = 'CURRENT_REQUEST';+const asyncLocalStorage = new AsyncLocalStorage();++function log(...args) {+  const store = asyncLocalStorage.getStore();+  // Make sure the store exists and it contains a request.+  if (store && store.has(kReq)) {+    const req = store.get(kReq);+    // Prints `GET /items ERR could not do something+    console.log(req.method, req.url, ...args);+  } else {+    console.log(...args);+  }+}++http.createServer((request, response) => {+  asyncLocalStorage.run(() => {+    const store = asyncLocalStorage.getStore();+    store.set(kReq, request);+    someAsyncOperation((err, result) => {+      if (err) {+        log('ERR', err.message);+      }+    });+  });+})+.listen(8080);+```++When having multiple instance of `AsyncLocalStorage`, they are independent+from each others. It is safe to instantiate this class multiple times.++### new AsyncLocalStorage()+<!-- YAML+added: REPLACEME+-->++* Returns: {Object}++Creates a new instance of `AsyncContext`. Storage is only provided within a+`run` or a `runSyncAndReturn` method call.++### asyncLocalStorage.getStore()+<!-- YAML+added: REPLACEME+-->++* Returns: {Map}++This methods returns the current store.+If this method is called  outside of an asynchronous context initialized by+calling `asyncLocalStorage.run` or `asyncLocalStorage.runAndReturn`, it will+return `undefined`.++### asyncLocalStorage.run(callback\[, ...args\])+<!-- YAML+added: REPLACEME+-->++* `callback` {Function}+* `...args` {any}++Calling `asyncLocalStorage.run(callback)` will create a new asynchronous+context.+Within the callback function and the asynchronous operations from the callback,+`asyncLocalStorage.getStore()` will return an instance of `Map` known as+"the store". This store will be persistent through the following+asynchronous calls.++The callback will be ran asynchronously.++If an error is thrown by the callback function. It won't be caught by a+a `try/catch` block as the callback is ran in a new asynchronous resource.+Also, the stacktrace will be impacted by the asynchronous call.++Optionally, arguments can be passed to the function, they will be passed to+the callback function.++#### example+```js+asyncLocalStorage.run(() => {+  asyncLocalStorage.getStore(); // Will return a Map+  someAsyncOperation(() => {+    asyncLocalStorage.getStore(); // Will return the same Map+  });+});+asyncLocalStorage.getStore(); // Will return undefined+```++### asyncLocalStorage.exit(callback\[, ...args\])+<!-- YAML+added: REPLACEME+-->++* `callback` {Function}+* `...args` {any}++Calling `asyncLocalStorage.exit(callback)` will create a new asynchronous+context.+Within the callback function and the asynchronous operations from the callback,+`asyncLocalStorage.getStore()` will return `undefined`.+The callback will be ran asynchronously.++If an error is thrown by the callback function. It won't be caught by a+a `try/catch` block as the callback is ran in a new asynchronous resource.+Also, the stacktrace will be impacted by the asynchronous call.++Optionally, arguments can be passed to the function, they will be passed to+the callback function.++#### example+```js+asyncLocalStorage.run(() => {+  asyncLocalStorage.getStore(); // Will return a Map+  asyncLocalStorage.exit(() => {+    asyncLocalStorage.getStore(); // Will return undefined+  });+  asyncLocalStorage.getStore(); // Will return the same Map+});+```++### asyncLocalStorage.runSyncAndReturn(callback\[, ...args\])+<!-- YAML+added: REPLACEME+-->++* `callback` {Function}+* `...args` {any}++This methods runs a function synchronously within a context and return its+return value. The store is not accessible outside of the callback function or+the asynchronous operations created within the callback.++If the callback function throws an error, it will be thrown by+`runSyncAndReturn` too. The stacktrace will not be impacted by this call and+the context will be excited.++Optionally, arguments can be passed to the function, they will be passed to+the callback function.++#### example+```js+try {+  asyncLocalStorage.runSyncAndReturn(() => {+    asyncLocalStorage.getStore(); // Will return a Map+    throw new Error();+  });+} catch (e) {+  asyncLocalStorage.getStore(); // Will return undefined+  // The error will be caught here+}+```++### asyncLocalStorage.exitSyncAndReturn(callback\[, ...args\])+<!-- YAML+added: REPLACEME+-->++* `callback` {Function}+* `...args` {any}++This methods runs a function synchronously outside of a context and return its+return value. The store is not accessible within the callback function or+the asynchronous operations created within the callback.++If the callback function throws an error, it will be thrown by+`exitSyncAndReturn` too. The stacktrace will not be impacted by this call and+the context will be re-entered.++Optionally, arguments can be passed to the function, they will be passed to+the callback function.++#### example+```js+// Within a call to run or runAsyncAndReturn+try {+  asyncLocalStorage.getStore(); // Will return a Map+  asyncLocalStorage.exitSyncAndReturn(() => {+    asyncLocalStorage.getStore(); // Will return undefined+    throw new Error();+  });+} catch (e) {+  asyncLocalStorage.getStore(); // Will return a Map+  // The error will be caught here+}+```++### Choosing between `run` and `runAsyncAndReturn`++#### When to choose `run`+`run` is asynchronous. It is called with a callback function that+runs within a new asynchronous call. This is the most explicit behavior as+everything that is executed within the callback of `run` (including further+asynchronous operations) will have access to the store.++If an instance of AsyncLocalStorage is used for error management (for instance+with `process.setUncaughtExceptionCaptureCallback`). Only the exceptions thrown+in the scope of the callback function will be associated with the context.++This method the safest to call as it provides strong scoping and consistent+behavior.++It can't be promisified using `util.promisify`. If needed, the `Promise`+constructor can be used:++```js+new Promise((resolve, reject) => {+  asyncLocalStorage.run(() => {+    someFunction((err, result) => {+      if (err) {+        return reject(err);+      }+      return resolve(result);+    });+  });+});+```++#### When to choose `runSyncAndReturn`+`runSyncAndReturn` is synchronous. The callback function will be executed+synchronously and it's return value will be returned by `runAndReturn`.
synchronously and its return value will be returned by `runSyncAndReturn`.
vdeturckheim

comment created time in 12 days

Pull request review commentnodejs/node

async-hooks: introduce async-storage API

 for (let i = 0; i < 10; i++) { } ``` +## Class: AsyncLocalStorage+<!-- YAML+added: REPLACEME+-->++This class is used to create asynchronous state within callbacks and promise+chains. It allows storing data throughout the lifetime of a web request+or any other asynchronous duration. It is similar to thread local storage+in other languages.++The following example builds a logger that will always know the current HTTP+request and uses it to display enhanced logs without needing to explicitly+provide the current HTTP request to it.++```js+const { AsyncLocalStorage } = require('async_hooks');+const http = require('http');++const kReq = 'CURRENT_REQUEST';+const asyncLocalStorage = new AsyncLocalStorage();++function log(...args) {+  const store = asyncLocalStorage.getStore();+  // Make sure the store exists and it contains a request.+  if (store && store.has(kReq)) {+    const req = store.get(kReq);+    // Prints `GET /items ERR could not do something+    console.log(req.method, req.url, ...args);+  } else {+    console.log(...args);+  }+}++http.createServer((request, response) => {+  asyncLocalStorage.run(() => {+    const store = asyncLocalStorage.getStore();+    store.set(kReq, request);+    someAsyncOperation((err, result) => {+      if (err) {+        log('ERR', err.message);+      }+    });+  });+})+.listen(8080);+```++When having multiple instance of `AsyncLocalStorage`, they are independent+from each others. It is safe to instantiate this class multiple times.++### new AsyncLocalStorage()+<!-- YAML+added: REPLACEME+-->++* Returns: {Object}++Creates a new instance of `AsyncContext`. Storage is only provided within a+`run` or a `runSyncAndReturn` method call.++### asyncLocalStorage.getStore()+<!-- YAML+added: REPLACEME+-->++* Returns: {Map}++This methods returns the current store.+If this method is called  outside of an asynchronous context initialized by+calling `asyncLocalStorage.run` or `asyncLocalStorage.runAndReturn`, it will+return `undefined`.++### asyncLocalStorage.run(callback\[, ...args\])+<!-- YAML+added: REPLACEME+-->++* `callback` {Function}+* `...args` {any}++Calling `asyncLocalStorage.run(callback)` will create a new asynchronous+context.+Within the callback function and the asynchronous operations from the callback,+`asyncLocalStorage.getStore()` will return an instance of `Map` known as+"the store". This store will be persistent through the following+asynchronous calls.++The callback will be ran asynchronously.++If an error is thrown by the callback function. It won't be caught by a+a `try/catch` block as the callback is ran in a new asynchronous resource.+Also, the stacktrace will be impacted by the asynchronous call.++Optionally, arguments can be passed to the function, they will be passed to+the callback function.++#### example+```js+asyncLocalStorage.run(() => {+  asyncLocalStorage.getStore(); // Will return a Map+  someAsyncOperation(() => {+    asyncLocalStorage.getStore(); // Will return the same Map+  });+});+asyncLocalStorage.getStore(); // Will return undefined+```++### asyncLocalStorage.exit(callback\[, ...args\])+<!-- YAML+added: REPLACEME+-->++* `callback` {Function}+* `...args` {any}++Calling `asyncLocalStorage.exit(callback)` will create a new asynchronous+context.+Within the callback function and the asynchronous operations from the callback,+`asyncLocalStorage.getStore()` will return `undefined`.+The callback will be ran asynchronously.++If an error is thrown by the callback function. It won't be caught by a+a `try/catch` block as the callback is ran in a new asynchronous resource.+Also, the stacktrace will be impacted by the asynchronous call.++Optionally, arguments can be passed to the function, they will be passed to+the callback function.++#### example+```js+asyncLocalStorage.run(() => {+  asyncLocalStorage.getStore(); // Will return a Map+  asyncLocalStorage.exit(() => {+    asyncLocalStorage.getStore(); // Will return undefined+  });+  asyncLocalStorage.getStore(); // Will return the same Map+});+```++### asyncLocalStorage.runSyncAndReturn(callback\[, ...args\])+<!-- YAML+added: REPLACEME+-->++* `callback` {Function}+* `...args` {any}++This methods runs a function synchronously within a context and return its+return value. The store is not accessible outside of the callback function or+the asynchronous operations created within the callback.++If the callback function throws an error, it will be thrown by+`runSyncAndReturn` too. The stacktrace will not be impacted by this call and+the context will be excited.++Optionally, arguments can be passed to the function, they will be passed to+the callback function.++#### example+```js+try {+  asyncLocalStorage.runSyncAndReturn(() => {+    asyncLocalStorage.getStore(); // Will return a Map+    throw new Error();+  });+} catch (e) {+  asyncLocalStorage.getStore(); // Will return undefined+  // The error will be caught here+}+```++### asyncLocalStorage.exitSyncAndReturn(callback\[, ...args\])+<!-- YAML+added: REPLACEME+-->++* `callback` {Function}+* `...args` {any}++This methods runs a function synchronously outside of a context and return its+return value. The store is not accessible within the callback function or+the asynchronous operations created within the callback.++If the callback function throws an error, it will be thrown by+`exitSyncAndReturn` too. The stacktrace will not be impacted by this call and+the context will be re-entered.++Optionally, arguments can be passed to the function, they will be passed to+the callback function.++#### example+```js+// Within a call to run or runAsyncAndReturn+try {+  asyncLocalStorage.getStore(); // Will return a Map+  asyncLocalStorage.exitSyncAndReturn(() => {+    asyncLocalStorage.getStore(); // Will return undefined+    throw new Error();+  });+} catch (e) {+  asyncLocalStorage.getStore(); // Will return a Map+  // The error will be caught here+}+```++### Choosing between `run` and `runAsyncAndReturn`++#### When to choose `run`+`run` is asynchronous. It is called with a callback function that+runs within a new asynchronous call. This is the most explicit behavior as+everything that is executed within the callback of `run` (including further+asynchronous operations) will have access to the store.++If an instance of AsyncLocalStorage is used for error management (for instance+with `process.setUncaughtExceptionCaptureCallback`). Only the exceptions thrown+in the scope of the callback function will be associated with the context.++This method the safest to call as it provides strong scoping and consistent+behavior.++It can't be promisified using `util.promisify`. If needed, the `Promise`+constructor can be used:++```js+new Promise((resolve, reject) => {+  asyncLocalStorage.run(() => {+    someFunction((err, result) => {+      if (err) {+        return reject(err);+      }+      return resolve(result);+    });+  });+});+```++#### When to choose `runSyncAndReturn`+`runSyncAndReturn` is synchronous. The callback function will be executed+synchronously and it's return value will be returned by `runAndReturn`.+The store will only be accessible from within the callback+function and the asynchronous operations created within this scope.+If the callback throws an error, `runAndReturn` will throw it and it will not+be associated with the context.++This method provides good scoping while being synchronous.++#### Usage with `async/await`+If, within an async function, only one `await` call is to run within a context,+the following pattern should be used:+```js+async function fn() {+  await asyncLocalStorage.runSyncAndReturn(() => {+    asyncLocalStorage.getStore().set('key', value);+    return foo(); // The return value of someFunction will be awaited
    return foo(); // The return value of foo will be awaited
vdeturckheim

comment created time in 12 days

Pull request review commentnodejs/node

async-hooks: introduce async-storage API

 for (let i = 0; i < 10; i++) { } ``` +## Class: AsyncLocalStorage+<!-- YAML+added: REPLACEME+-->++This class is used to create asynchronous state within callbacks and promise+chains. It allows storing data throughout the lifetime of a web request+or any other asynchronous duration. It is similar to thread local storage+in other languages.++The following example builds a logger that will always know the current HTTP+request and uses it to display enhanced logs without needing to explicitly+provide the current HTTP request to it.++```js+const { AsyncLocalStorage } = require('async_hooks');+const http = require('http');++const kReq = 'CURRENT_REQUEST';+const asyncLocalStorage = new AsyncLocalStorage();++function log(...args) {+  const store = asyncLocalStorage.getStore();+  // Make sure the store exists and it contains a request.+  if (store && store.has(kReq)) {+    const req = store.get(kReq);+    // Prints `GET /items ERR could not do something+    console.log(req.method, req.url, ...args);+  } else {+    console.log(...args);+  }+}++http.createServer((request, response) => {+  asyncLocalStorage.run(() => {+    const store = asyncLocalStorage.getStore();+    store.set(kReq, request);+    someAsyncOperation((err, result) => {+      if (err) {+        log('ERR', err.message);+      }+    });+  });+})+.listen(8080);+```++When having multiple instance of `AsyncLocalStorage`, they are independent+from each others. It is safe to instantiate this class multiple times.++### new AsyncLocalStorage()+<!-- YAML+added: REPLACEME+-->++* Returns: {Object}++Creates a new instance of `AsyncContext`. Storage is only provided within a+`run` or a `runSyncAndReturn` method call.++### asyncLocalStorage.getStore()+<!-- YAML+added: REPLACEME+-->++* Returns: {Map}++This methods returns the current store.+If this method is called  outside of an asynchronous context initialized by+calling `asyncLocalStorage.run` or `asyncLocalStorage.runAndReturn`, it will+return `undefined`.++### asyncLocalStorage.run(callback\[, ...args\])+<!-- YAML+added: REPLACEME+-->++* `callback` {Function}+* `...args` {any}++Calling `asyncLocalStorage.run(callback)` will create a new asynchronous+context.+Within the callback function and the asynchronous operations from the callback,+`asyncLocalStorage.getStore()` will return an instance of `Map` known as+"the store". This store will be persistent through the following+asynchronous calls.++The callback will be ran asynchronously.++If an error is thrown by the callback function. It won't be caught by a+a `try/catch` block as the callback is ran in a new asynchronous resource.+Also, the stacktrace will be impacted by the asynchronous call.++Optionally, arguments can be passed to the function, they will be passed to+the callback function.++#### example+```js+asyncLocalStorage.run(() => {+  asyncLocalStorage.getStore(); // Will return a Map+  someAsyncOperation(() => {+    asyncLocalStorage.getStore(); // Will return the same Map+  });+});+asyncLocalStorage.getStore(); // Will return undefined+```++### asyncLocalStorage.exit(callback\[, ...args\])+<!-- YAML+added: REPLACEME+-->++* `callback` {Function}+* `...args` {any}++Calling `asyncLocalStorage.exit(callback)` will create a new asynchronous+context.+Within the callback function and the asynchronous operations from the callback,+`asyncLocalStorage.getStore()` will return `undefined`.+The callback will be ran asynchronously.++If an error is thrown by the callback function. It won't be caught by a+a `try/catch` block as the callback is ran in a new asynchronous resource.+Also, the stacktrace will be impacted by the asynchronous call.++Optionally, arguments can be passed to the function, they will be passed to+the callback function.++#### example+```js+asyncLocalStorage.run(() => {+  asyncLocalStorage.getStore(); // Will return a Map+  asyncLocalStorage.exit(() => {+    asyncLocalStorage.getStore(); // Will return undefined+  });+  asyncLocalStorage.getStore(); // Will return the same Map+});+```++### asyncLocalStorage.runSyncAndReturn(callback\[, ...args\])+<!-- YAML+added: REPLACEME+-->++* `callback` {Function}+* `...args` {any}++This methods runs a function synchronously within a context and return its+return value. The store is not accessible outside of the callback function or+the asynchronous operations created within the callback.++If the callback function throws an error, it will be thrown by+`runSyncAndReturn` too. The stacktrace will not be impacted by this call and+the context will be excited.++Optionally, arguments can be passed to the function, they will be passed to+the callback function.++#### example+```js+try {+  asyncLocalStorage.runSyncAndReturn(() => {+    asyncLocalStorage.getStore(); // Will return a Map+    throw new Error();+  });+} catch (e) {+  asyncLocalStorage.getStore(); // Will return undefined+  // The error will be caught here+}+```++### asyncLocalStorage.exitSyncAndReturn(callback\[, ...args\])+<!-- YAML+added: REPLACEME+-->++* `callback` {Function}+* `...args` {any}++This methods runs a function synchronously outside of a context and return its+return value. The store is not accessible within the callback function or+the asynchronous operations created within the callback.++If the callback function throws an error, it will be thrown by+`exitSyncAndReturn` too. The stacktrace will not be impacted by this call and+the context will be re-entered.++Optionally, arguments can be passed to the function, they will be passed to+the callback function.++#### example+```js+// Within a call to run or runAsyncAndReturn+try {+  asyncLocalStorage.getStore(); // Will return a Map+  asyncLocalStorage.exitSyncAndReturn(() => {+    asyncLocalStorage.getStore(); // Will return undefined+    throw new Error();+  });+} catch (e) {+  asyncLocalStorage.getStore(); // Will return a Map+  // The error will be caught here+}+```++### Choosing between `run` and `runAsyncAndReturn`++#### When to choose `run`+`run` is asynchronous. It is called with a callback function that+runs within a new asynchronous call. This is the most explicit behavior as+everything that is executed within the callback of `run` (including further+asynchronous operations) will have access to the store.++If an instance of AsyncLocalStorage is used for error management (for instance+with `process.setUncaughtExceptionCaptureCallback`). Only the exceptions thrown+in the scope of the callback function will be associated with the context.++This method the safest to call as it provides strong scoping and consistent
This method is the safest to call as it provides strong scoping and consistent
vdeturckheim

comment created time in 12 days

Pull request review commentnodejs/node

async-hooks: introduce async-storage API

 for (let i = 0; i < 10; i++) { } ``` +## Class: AsyncLocalStorage+<!-- YAML+added: REPLACEME+-->++This class is used to create asynchronous state within callbacks and promise+chains. It allows storing data throughout the lifetime of a web request+or any other asynchronous duration. It is similar to thread local storage+in other languages.++The following example builds a logger that will always know the current HTTP+request and uses it to display enhanced logs without needing to explicitly+provide the current HTTP request to it.++```js+const { AsyncLocalStorage } = require('async_hooks');+const http = require('http');++const kReq = 'CURRENT_REQUEST';+const asyncLocalStorage = new AsyncLocalStorage();++function log(...args) {+  const store = asyncLocalStorage.getStore();+  // Make sure the store exists and it contains a request.+  if (store && store.has(kReq)) {+    const req = store.get(kReq);+    // Prints `GET /items ERR could not do something+    console.log(req.method, req.url, ...args);+  } else {+    console.log(...args);+  }+}++http.createServer((request, response) => {+  asyncLocalStorage.run(() => {+    const store = asyncLocalStorage.getStore();+    store.set(kReq, request);+    someAsyncOperation((err, result) => {+      if (err) {+        log('ERR', err.message);+      }+    });+  });+})+.listen(8080);+```++When having multiple instance of `AsyncLocalStorage`, they are independent+from each others. It is safe to instantiate this class multiple times.++### new AsyncLocalStorage()+<!-- YAML+added: REPLACEME+-->++* Returns: {Object}++Creates a new instance of `AsyncContext`. Storage is only provided within a+`run` or a `runSyncAndReturn` method call.++### asyncLocalStorage.getStore()+<!-- YAML+added: REPLACEME+-->++* Returns: {Map}++This methods returns the current store.+If this method is called  outside of an asynchronous context initialized by+calling `asyncLocalStorage.run` or `asyncLocalStorage.runAndReturn`, it will+return `undefined`.++### asyncLocalStorage.run(callback\[, ...args\])+<!-- YAML+added: REPLACEME+-->++* `callback` {Function}+* `...args` {any}++Calling `asyncLocalStorage.run(callback)` will create a new asynchronous+context.+Within the callback function and the asynchronous operations from the callback,+`asyncLocalStorage.getStore()` will return an instance of `Map` known as+"the store". This store will be persistent through the following+asynchronous calls.++The callback will be ran asynchronously.++If an error is thrown by the callback function. It won't be caught by a+a `try/catch` block as the callback is ran in a new asynchronous resource.+Also, the stacktrace will be impacted by the asynchronous call.++Optionally, arguments can be passed to the function, they will be passed to+the callback function.++#### example+```js+asyncLocalStorage.run(() => {+  asyncLocalStorage.getStore(); // Will return a Map+  someAsyncOperation(() => {+    asyncLocalStorage.getStore(); // Will return the same Map+  });+});+asyncLocalStorage.getStore(); // Will return undefined+```++### asyncLocalStorage.exit(callback\[, ...args\])+<!-- YAML+added: REPLACEME+-->++* `callback` {Function}+* `...args` {any}++Calling `asyncLocalStorage.exit(callback)` will create a new asynchronous+context.+Within the callback function and the asynchronous operations from the callback,+`asyncLocalStorage.getStore()` will return `undefined`.+The callback will be ran asynchronously.++If an error is thrown by the callback function. It won't be caught by a+a `try/catch` block as the callback is ran in a new asynchronous resource.+Also, the stacktrace will be impacted by the asynchronous call.++Optionally, arguments can be passed to the function, they will be passed to+the callback function.++#### example+```js+asyncLocalStorage.run(() => {+  asyncLocalStorage.getStore(); // Will return a Map+  asyncLocalStorage.exit(() => {+    asyncLocalStorage.getStore(); // Will return undefined+  });+  asyncLocalStorage.getStore(); // Will return the same Map+});+```++### asyncLocalStorage.runSyncAndReturn(callback\[, ...args\])+<!-- YAML+added: REPLACEME+-->++* `callback` {Function}+* `...args` {any}++This methods runs a function synchronously within a context and return its+return value. The store is not accessible outside of the callback function or+the asynchronous operations created within the callback.++If the callback function throws an error, it will be thrown by+`runSyncAndReturn` too. The stacktrace will not be impacted by this call and+the context will be excited.++Optionally, arguments can be passed to the function, they will be passed to
Optionally, arguments can be passed to the function. They will be passed to
vdeturckheim

comment created time in 12 days

Pull request review commentnodejs/node

async-hooks: introduce async-storage API

 for (let i = 0; i < 10; i++) { } ``` +## Class: AsyncLocalStorage+<!-- YAML+added: REPLACEME+-->++This class is used to create asynchronous state within callbacks and promise+chains. It allows storing data throughout the lifetime of a web request+or any other asynchronous duration. It is similar to thread local storage+in other languages.++The following example builds a logger that will always know the current HTTP+request and uses it to display enhanced logs without needing to explicitly+provide the current HTTP request to it.++```js+const { AsyncLocalStorage } = require('async_hooks');+const http = require('http');++const kReq = 'CURRENT_REQUEST';+const asyncLocalStorage = new AsyncLocalStorage();++function log(...args) {+  const store = asyncLocalStorage.getStore();+  // Make sure the store exists and it contains a request.+  if (store && store.has(kReq)) {+    const req = store.get(kReq);+    // Prints `GET /items ERR could not do something+    console.log(req.method, req.url, ...args);+  } else {+    console.log(...args);+  }+}++http.createServer((request, response) => {+  asyncLocalStorage.run(() => {+    const store = asyncLocalStorage.getStore();+    store.set(kReq, request);+    someAsyncOperation((err, result) => {+      if (err) {+        log('ERR', err.message);+      }+    });+  });+})+.listen(8080);+```++When having multiple instance of `AsyncLocalStorage`, they are independent+from each others. It is safe to instantiate this class multiple times.++### new AsyncLocalStorage()+<!-- YAML+added: REPLACEME+-->++* Returns: {Object}++Creates a new instance of `AsyncContext`. Storage is only provided within a+`run` or a `runSyncAndReturn` method call.++### asyncLocalStorage.getStore()+<!-- YAML+added: REPLACEME+-->++* Returns: {Map}++This methods returns the current store.+If this method is called  outside of an asynchronous context initialized by+calling `asyncLocalStorage.run` or `asyncLocalStorage.runAndReturn`, it will+return `undefined`.++### asyncLocalStorage.run(callback\[, ...args\])+<!-- YAML+added: REPLACEME+-->++* `callback` {Function}+* `...args` {any}++Calling `asyncLocalStorage.run(callback)` will create a new asynchronous+context.+Within the callback function and the asynchronous operations from the callback,+`asyncLocalStorage.getStore()` will return an instance of `Map` known as+"the store". This store will be persistent through the following+asynchronous calls.++The callback will be ran asynchronously.++If an error is thrown by the callback function. It won't be caught by a+a `try/catch` block as the callback is ran in a new asynchronous resource.+Also, the stacktrace will be impacted by the asynchronous call.++Optionally, arguments can be passed to the function, they will be passed to+the callback function.++#### example+```js+asyncLocalStorage.run(() => {+  asyncLocalStorage.getStore(); // Will return a Map+  someAsyncOperation(() => {+    asyncLocalStorage.getStore(); // Will return the same Map+  });+});+asyncLocalStorage.getStore(); // Will return undefined+```++### asyncLocalStorage.exit(callback\[, ...args\])+<!-- YAML+added: REPLACEME+-->++* `callback` {Function}+* `...args` {any}++Calling `asyncLocalStorage.exit(callback)` will create a new asynchronous+context.+Within the callback function and the asynchronous operations from the callback,+`asyncLocalStorage.getStore()` will return `undefined`.+The callback will be ran asynchronously.++If an error is thrown by the callback function. It won't be caught by a+a `try/catch` block as the callback is ran in a new asynchronous resource.+Also, the stacktrace will be impacted by the asynchronous call.++Optionally, arguments can be passed to the function, they will be passed to+the callback function.++#### example+```js+asyncLocalStorage.run(() => {+  asyncLocalStorage.getStore(); // Will return a Map+  asyncLocalStorage.exit(() => {+    asyncLocalStorage.getStore(); // Will return undefined+  });+  asyncLocalStorage.getStore(); // Will return the same Map+});+```++### asyncLocalStorage.runSyncAndReturn(callback\[, ...args\])+<!-- YAML+added: REPLACEME+-->++* `callback` {Function}+* `...args` {any}++This methods runs a function synchronously within a context and return its+return value. The store is not accessible outside of the callback function or+the asynchronous operations created within the callback.++If the callback function throws an error, it will be thrown by+`runSyncAndReturn` too. The stacktrace will not be impacted by this call and+the context will be excited.++Optionally, arguments can be passed to the function, they will be passed to+the callback function.++#### example+```js+try {+  asyncLocalStorage.runSyncAndReturn(() => {+    asyncLocalStorage.getStore(); // Will return a Map+    throw new Error();+  });+} catch (e) {+  asyncLocalStorage.getStore(); // Will return undefined+  // The error will be caught here+}+```++### asyncLocalStorage.exitSyncAndReturn(callback\[, ...args\])+<!-- YAML+added: REPLACEME+-->++* `callback` {Function}+* `...args` {any}++This methods runs a function synchronously outside of a context and return its+return value. The store is not accessible within the callback function or+the asynchronous operations created within the callback.++If the callback function throws an error, it will be thrown by+`exitSyncAndReturn` too. The stacktrace will not be impacted by this call and+the context will be re-entered.++Optionally, arguments can be passed to the function, they will be passed to+the callback function.++#### example
Example:

vdeturckheim

comment created time in 12 days

Pull request review commentnodejs/node

async-hooks: introduce async-storage API

 for (let i = 0; i < 10; i++) { } ``` +## Class: AsyncLocalStorage+<!-- YAML+added: REPLACEME+-->++This class is used to create asynchronous state within callbacks and promise+chains. It allows storing data throughout the lifetime of a web request+or any other asynchronous duration. It is similar to thread local storage+in other languages.++The following example builds a logger that will always know the current HTTP+request and uses it to display enhanced logs without needing to explicitly+provide the current HTTP request to it.++```js+const { AsyncLocalStorage } = require('async_hooks');+const http = require('http');++const kReq = 'CURRENT_REQUEST';+const asyncLocalStorage = new AsyncLocalStorage();++function log(...args) {+  const store = asyncLocalStorage.getStore();+  // Make sure the store exists and it contains a request.+  if (store && store.has(kReq)) {+    const req = store.get(kReq);+    // Prints `GET /items ERR could not do something+    console.log(req.method, req.url, ...args);+  } else {+    console.log(...args);+  }+}++http.createServer((request, response) => {+  asyncLocalStorage.run(() => {+    const store = asyncLocalStorage.getStore();+    store.set(kReq, request);+    someAsyncOperation((err, result) => {+      if (err) {+        log('ERR', err.message);+      }+    });+  });+})+.listen(8080);+```++When having multiple instance of `AsyncLocalStorage`, they are independent+from each others. It is safe to instantiate this class multiple times.++### new AsyncLocalStorage()+<!-- YAML+added: REPLACEME+-->++* Returns: {Object}++Creates a new instance of `AsyncContext`. Storage is only provided within a+`run` or a `runSyncAndReturn` method call.++### asyncLocalStorage.getStore()+<!-- YAML+added: REPLACEME+-->++* Returns: {Map}++This methods returns the current store.+If this method is called  outside of an asynchronous context initialized by+calling `asyncLocalStorage.run` or `asyncLocalStorage.runAndReturn`, it will+return `undefined`.++### asyncLocalStorage.run(callback\[, ...args\])+<!-- YAML+added: REPLACEME+-->++* `callback` {Function}+* `...args` {any}++Calling `asyncLocalStorage.run(callback)` will create a new asynchronous+context.+Within the callback function and the asynchronous operations from the callback,+`asyncLocalStorage.getStore()` will return an instance of `Map` known as+"the store". This store will be persistent through the following+asynchronous calls.++The callback will be ran asynchronously.++If an error is thrown by the callback function. It won't be caught by a+a `try/catch` block as the callback is ran in a new asynchronous resource.+Also, the stacktrace will be impacted by the asynchronous call.++Optionally, arguments can be passed to the function, they will be passed to+the callback function.++#### example+```js+asyncLocalStorage.run(() => {+  asyncLocalStorage.getStore(); // Will return a Map+  someAsyncOperation(() => {+    asyncLocalStorage.getStore(); // Will return the same Map+  });+});+asyncLocalStorage.getStore(); // Will return undefined+```++### asyncLocalStorage.exit(callback\[, ...args\])+<!-- YAML+added: REPLACEME+-->++* `callback` {Function}+* `...args` {any}++Calling `asyncLocalStorage.exit(callback)` will create a new asynchronous+context.+Within the callback function and the asynchronous operations from the callback,+`asyncLocalStorage.getStore()` will return `undefined`.+The callback will be ran asynchronously.++If an error is thrown by the callback function. It won't be caught by a+a `try/catch` block as the callback is ran in a new asynchronous resource.+Also, the stacktrace will be impacted by the asynchronous call.++Optionally, arguments can be passed to the function, they will be passed to+the callback function.++#### example+```js+asyncLocalStorage.run(() => {+  asyncLocalStorage.getStore(); // Will return a Map+  asyncLocalStorage.exit(() => {+    asyncLocalStorage.getStore(); // Will return undefined+  });+  asyncLocalStorage.getStore(); // Will return the same Map+});+```++### asyncLocalStorage.runSyncAndReturn(callback\[, ...args\])
### `asyncLocalStorage.runSyncAndReturn(callback[, ...args])`
vdeturckheim

comment created time in 12 days

Pull request review commentnodejs/node

async-hooks: introduce async-storage API

 for (let i = 0; i < 10; i++) { } ``` +## Class: AsyncLocalStorage+<!-- YAML+added: REPLACEME+-->++This class is used to create asynchronous state within callbacks and promise+chains. It allows storing data throughout the lifetime of a web request+or any other asynchronous duration. It is similar to thread local storage+in other languages.++The following example builds a logger that will always know the current HTTP+request and uses it to display enhanced logs without needing to explicitly+provide the current HTTP request to it.++```js+const { AsyncLocalStorage } = require('async_hooks');+const http = require('http');++const kReq = 'CURRENT_REQUEST';+const asyncLocalStorage = new AsyncLocalStorage();++function log(...args) {+  const store = asyncLocalStorage.getStore();+  // Make sure the store exists and it contains a request.+  if (store && store.has(kReq)) {+    const req = store.get(kReq);+    // Prints `GET /items ERR could not do something+    console.log(req.method, req.url, ...args);+  } else {+    console.log(...args);+  }+}++http.createServer((request, response) => {+  asyncLocalStorage.run(() => {+    const store = asyncLocalStorage.getStore();+    store.set(kReq, request);+    someAsyncOperation((err, result) => {+      if (err) {+        log('ERR', err.message);+      }+    });+  });+})+.listen(8080);+```++When having multiple instance of `AsyncLocalStorage`, they are independent+from each others. It is safe to instantiate this class multiple times.++### new AsyncLocalStorage()+<!-- YAML+added: REPLACEME+-->++* Returns: {Object}++Creates a new instance of `AsyncContext`. Storage is only provided within a+`run` or a `runSyncAndReturn` method call.++### asyncLocalStorage.getStore()+<!-- YAML+added: REPLACEME+-->++* Returns: {Map}++This methods returns the current store.+If this method is called  outside of an asynchronous context initialized by+calling `asyncLocalStorage.run` or `asyncLocalStorage.runAndReturn`, it will+return `undefined`.++### asyncLocalStorage.run(callback\[, ...args\])+<!-- YAML+added: REPLACEME+-->++* `callback` {Function}+* `...args` {any}++Calling `asyncLocalStorage.run(callback)` will create a new asynchronous+context.+Within the callback function and the asynchronous operations from the callback,+`asyncLocalStorage.getStore()` will return an instance of `Map` known as+"the store". This store will be persistent through the following+asynchronous calls.++The callback will be ran asynchronously.++If an error is thrown by the callback function. It won't be caught by a+a `try/catch` block as the callback is ran in a new asynchronous resource.+Also, the stacktrace will be impacted by the asynchronous call.++Optionally, arguments can be passed to the function, they will be passed to+the callback function.++#### example+```js+asyncLocalStorage.run(() => {+  asyncLocalStorage.getStore(); // Will return a Map+  someAsyncOperation(() => {+    asyncLocalStorage.getStore(); // Will return the same Map+  });+});+asyncLocalStorage.getStore(); // Will return undefined+```++### asyncLocalStorage.exit(callback\[, ...args\])+<!-- YAML+added: REPLACEME+-->++* `callback` {Function}+* `...args` {any}++Calling `asyncLocalStorage.exit(callback)` will create a new asynchronous+context.+Within the callback function and the asynchronous operations from the callback,+`asyncLocalStorage.getStore()` will return `undefined`.+The callback will be ran asynchronously.++If an error is thrown by the callback function. It won't be caught by a+a `try/catch` block as the callback is ran in a new asynchronous resource.+Also, the stacktrace will be impacted by the asynchronous call.++Optionally, arguments can be passed to the function, they will be passed to+the callback function.++#### example+```js+asyncLocalStorage.run(() => {+  asyncLocalStorage.getStore(); // Will return a Map+  asyncLocalStorage.exit(() => {+    asyncLocalStorage.getStore(); // Will return undefined+  });+  asyncLocalStorage.getStore(); // Will return the same Map+});+```++### asyncLocalStorage.runSyncAndReturn(callback\[, ...args\])+<!-- YAML+added: REPLACEME+-->++* `callback` {Function}+* `...args` {any}++This methods runs a function synchronously within a context and return its+return value. The store is not accessible outside of the callback function or+the asynchronous operations created within the callback.++If the callback function throws an error, it will be thrown by+`runSyncAndReturn` too. The stacktrace will not be impacted by this call and+the context will be excited.++Optionally, arguments can be passed to the function, they will be passed to+the callback function.++#### example+```js+try {+  asyncLocalStorage.runSyncAndReturn(() => {+    asyncLocalStorage.getStore(); // Will return a Map+    throw new Error();+  });+} catch (e) {+  asyncLocalStorage.getStore(); // Will return undefined+  // The error will be caught here+}+```++### asyncLocalStorage.exitSyncAndReturn(callback\[, ...args\])+<!-- YAML+added: REPLACEME+-->++* `callback` {Function}+* `...args` {any}++This methods runs a function synchronously outside of a context and return its+return value. The store is not accessible within the callback function or+the asynchronous operations created within the callback.++If the callback function throws an error, it will be thrown by+`exitSyncAndReturn` too. The stacktrace will not be impacted by this call and+the context will be re-entered.++Optionally, arguments can be passed to the function, they will be passed to
Optionally, arguments can be passed to the function. They will be passed to
vdeturckheim

comment created time in 12 days

Pull request review commentnodejs/node

async-hooks: introduce async-storage API

 for (let i = 0; i < 10; i++) { } ``` +## Class: AsyncLocalStorage+<!-- YAML+added: REPLACEME+-->++This class is used to create asynchronous state within callbacks and promise+chains. It allows storing data throughout the lifetime of a web request+or any other asynchronous duration. It is similar to thread local storage+in other languages.++The following example builds a logger that will always know the current HTTP+request and uses it to display enhanced logs without needing to explicitly+provide the current HTTP request to it.++```js+const { AsyncLocalStorage } = require('async_hooks');+const http = require('http');++const kReq = 'CURRENT_REQUEST';+const asyncLocalStorage = new AsyncLocalStorage();++function log(...args) {+  const store = asyncLocalStorage.getStore();+  // Make sure the store exists and it contains a request.+  if (store && store.has(kReq)) {+    const req = store.get(kReq);+    // Prints `GET /items ERR could not do something+    console.log(req.method, req.url, ...args);+  } else {+    console.log(...args);+  }+}++http.createServer((request, response) => {+  asyncLocalStorage.run(() => {+    const store = asyncLocalStorage.getStore();+    store.set(kReq, request);+    someAsyncOperation((err, result) => {+      if (err) {+        log('ERR', err.message);+      }+    });+  });+})+.listen(8080);+```++When having multiple instance of `AsyncLocalStorage`, they are independent+from each others. It is safe to instantiate this class multiple times.++### new AsyncLocalStorage()+<!-- YAML+added: REPLACEME+-->++* Returns: {Object}++Creates a new instance of `AsyncContext`. Storage is only provided within a+`run` or a `runSyncAndReturn` method call.++### asyncLocalStorage.getStore()+<!-- YAML+added: REPLACEME+-->++* Returns: {Map}++This methods returns the current store.+If this method is called  outside of an asynchronous context initialized by+calling `asyncLocalStorage.run` or `asyncLocalStorage.runAndReturn`, it will+return `undefined`.++### asyncLocalStorage.run(callback\[, ...args\])+<!-- YAML+added: REPLACEME+-->++* `callback` {Function}+* `...args` {any}++Calling `asyncLocalStorage.run(callback)` will create a new asynchronous+context.+Within the callback function and the asynchronous operations from the callback,+`asyncLocalStorage.getStore()` will return an instance of `Map` known as+"the store". This store will be persistent through the following+asynchronous calls.++The callback will be ran asynchronously.++If an error is thrown by the callback function. It won't be caught by a+a `try/catch` block as the callback is ran in a new asynchronous resource.+Also, the stacktrace will be impacted by the asynchronous call.++Optionally, arguments can be passed to the function, they will be passed to+the callback function.++#### example+```js+asyncLocalStorage.run(() => {+  asyncLocalStorage.getStore(); // Will return a Map+  someAsyncOperation(() => {+    asyncLocalStorage.getStore(); // Will return the same Map+  });+});+asyncLocalStorage.getStore(); // Will return undefined+```++### asyncLocalStorage.exit(callback\[, ...args\])+<!-- YAML+added: REPLACEME+-->++* `callback` {Function}+* `...args` {any}++Calling `asyncLocalStorage.exit(callback)` will create a new asynchronous+context.+Within the callback function and the asynchronous operations from the callback,+`asyncLocalStorage.getStore()` will return `undefined`.+The callback will be ran asynchronously.++If an error is thrown by the callback function. It won't be caught by a+a `try/catch` block as the callback is ran in a new asynchronous resource.+Also, the stacktrace will be impacted by the asynchronous call.++Optionally, arguments can be passed to the function, they will be passed to+the callback function.++#### example+```js+asyncLocalStorage.run(() => {+  asyncLocalStorage.getStore(); // Will return a Map+  asyncLocalStorage.exit(() => {+    asyncLocalStorage.getStore(); // Will return undefined+  });+  asyncLocalStorage.getStore(); // Will return the same Map+});+```++### asyncLocalStorage.runSyncAndReturn(callback\[, ...args\])+<!-- YAML+added: REPLACEME+-->++* `callback` {Function}+* `...args` {any}++This methods runs a function synchronously within a context and return its+return value. The store is not accessible outside of the callback function or+the asynchronous operations created within the callback.++If the callback function throws an error, it will be thrown by+`runSyncAndReturn` too. The stacktrace will not be impacted by this call and+the context will be excited.++Optionally, arguments can be passed to the function, they will be passed to+the callback function.++#### example+```js+try {+  asyncLocalStorage.runSyncAndReturn(() => {+    asyncLocalStorage.getStore(); // Will return a Map
    asyncLocalStorage.getStore(); // Returns a Map
vdeturckheim

comment created time in 12 days

Pull request review commentnodejs/node

async-hooks: introduce async-storage API

 for (let i = 0; i < 10; i++) { } ``` +## Class: AsyncLocalStorage+<!-- YAML+added: REPLACEME+-->++This class is used to create asynchronous state within callbacks and promise+chains. It allows storing data throughout the lifetime of a web request+or any other asynchronous duration. It is similar to thread local storage+in other languages.++The following example builds a logger that will always know the current HTTP+request and uses it to display enhanced logs without needing to explicitly+provide the current HTTP request to it.++```js+const { AsyncLocalStorage } = require('async_hooks');+const http = require('http');++const kReq = 'CURRENT_REQUEST';+const asyncLocalStorage = new AsyncLocalStorage();++function log(...args) {+  const store = asyncLocalStorage.getStore();+  // Make sure the store exists and it contains a request.+  if (store && store.has(kReq)) {+    const req = store.get(kReq);+    // Prints `GET /items ERR could not do something+    console.log(req.method, req.url, ...args);+  } else {+    console.log(...args);+  }+}++http.createServer((request, response) => {+  asyncLocalStorage.run(() => {+    const store = asyncLocalStorage.getStore();+    store.set(kReq, request);+    someAsyncOperation((err, result) => {+      if (err) {+        log('ERR', err.message);+      }+    });+  });+})+.listen(8080);+```++When having multiple instance of `AsyncLocalStorage`, they are independent+from each others. It is safe to instantiate this class multiple times.++### new AsyncLocalStorage()+<!-- YAML+added: REPLACEME+-->++* Returns: {Object}++Creates a new instance of `AsyncContext`. Storage is only provided within a+`run` or a `runSyncAndReturn` method call.++### asyncLocalStorage.getStore()+<!-- YAML+added: REPLACEME+-->++* Returns: {Map}++This methods returns the current store.+If this method is called  outside of an asynchronous context initialized by+calling `asyncLocalStorage.run` or `asyncLocalStorage.runAndReturn`, it will+return `undefined`.++### asyncLocalStorage.run(callback\[, ...args\])+<!-- YAML+added: REPLACEME+-->++* `callback` {Function}+* `...args` {any}++Calling `asyncLocalStorage.run(callback)` will create a new asynchronous+context.+Within the callback function and the asynchronous operations from the callback,+`asyncLocalStorage.getStore()` will return an instance of `Map` known as+"the store". This store will be persistent through the following+asynchronous calls.++The callback will be ran asynchronously.++If an error is thrown by the callback function. It won't be caught by a+a `try/catch` block as the callback is ran in a new asynchronous resource.+Also, the stacktrace will be impacted by the asynchronous call.++Optionally, arguments can be passed to the function, they will be passed to+the callback function.++#### example+```js+asyncLocalStorage.run(() => {+  asyncLocalStorage.getStore(); // Will return a Map+  someAsyncOperation(() => {+    asyncLocalStorage.getStore(); // Will return the same Map+  });+});+asyncLocalStorage.getStore(); // Will return undefined+```++### asyncLocalStorage.exit(callback\[, ...args\])+<!-- YAML+added: REPLACEME+-->++* `callback` {Function}+* `...args` {any}++Calling `asyncLocalStorage.exit(callback)` will create a new asynchronous+context.+Within the callback function and the asynchronous operations from the callback,+`asyncLocalStorage.getStore()` will return `undefined`.+The callback will be ran asynchronously.++If an error is thrown by the callback function. It won't be caught by a+a `try/catch` block as the callback is ran in a new asynchronous resource.+Also, the stacktrace will be impacted by the asynchronous call.++Optionally, arguments can be passed to the function, they will be passed to+the callback function.++#### example+```js+asyncLocalStorage.run(() => {+  asyncLocalStorage.getStore(); // Will return a Map+  asyncLocalStorage.exit(() => {+    asyncLocalStorage.getStore(); // Will return undefined+  });+  asyncLocalStorage.getStore(); // Will return the same Map+});+```++### asyncLocalStorage.runSyncAndReturn(callback\[, ...args\])+<!-- YAML+added: REPLACEME+-->++* `callback` {Function}+* `...args` {any}++This methods runs a function synchronously within a context and return its+return value. The store is not accessible outside of the callback function or+the asynchronous operations created within the callback.++If the callback function throws an error, it will be thrown by+`runSyncAndReturn` too. The stacktrace will not be impacted by this call and+the context will be excited.
the context will be exited.
vdeturckheim

comment created time in 12 days

Pull request review commentnodejs/node

async-hooks: introduce async-storage API

 for (let i = 0; i < 10; i++) { } ``` +## Class: AsyncLocalStorage+<!-- YAML+added: REPLACEME+-->++This class is used to create asynchronous state within callbacks and promise+chains. It allows storing data throughout the lifetime of a web request+or any other asynchronous duration. It is similar to thread local storage+in other languages.++The following example builds a logger that will always know the current HTTP+request and uses it to display enhanced logs without needing to explicitly+provide the current HTTP request to it.++```js+const { AsyncLocalStorage } = require('async_hooks');+const http = require('http');++const kReq = 'CURRENT_REQUEST';+const asyncLocalStorage = new AsyncLocalStorage();++function log(...args) {+  const store = asyncLocalStorage.getStore();+  // Make sure the store exists and it contains a request.+  if (store && store.has(kReq)) {+    const req = store.get(kReq);+    // Prints `GET /items ERR could not do something+    console.log(req.method, req.url, ...args);+  } else {+    console.log(...args);+  }+}++http.createServer((request, response) => {+  asyncLocalStorage.run(() => {+    const store = asyncLocalStorage.getStore();+    store.set(kReq, request);+    someAsyncOperation((err, result) => {+      if (err) {+        log('ERR', err.message);+      }+    });+  });+})+.listen(8080);+```++When having multiple instance of `AsyncLocalStorage`, they are independent+from each others. It is safe to instantiate this class multiple times.++### new AsyncLocalStorage()+<!-- YAML+added: REPLACEME+-->++* Returns: {Object}++Creates a new instance of `AsyncContext`. Storage is only provided within a+`run` or a `runSyncAndReturn` method call.++### asyncLocalStorage.getStore()+<!-- YAML+added: REPLACEME+-->++* Returns: {Map}++This methods returns the current store.+If this method is called  outside of an asynchronous context initialized by+calling `asyncLocalStorage.run` or `asyncLocalStorage.runAndReturn`, it will+return `undefined`.++### asyncLocalStorage.run(callback\[, ...args\])+<!-- YAML+added: REPLACEME+-->++* `callback` {Function}+* `...args` {any}++Calling `asyncLocalStorage.run(callback)` will create a new asynchronous+context.+Within the callback function and the asynchronous operations from the callback,+`asyncLocalStorage.getStore()` will return an instance of `Map` known as+"the store". This store will be persistent through the following+asynchronous calls.++The callback will be ran asynchronously.++If an error is thrown by the callback function. It won't be caught by a+a `try/catch` block as the callback is ran in a new asynchronous resource.+Also, the stacktrace will be impacted by the asynchronous call.++Optionally, arguments can be passed to the function, they will be passed to+the callback function.++#### example+```js+asyncLocalStorage.run(() => {+  asyncLocalStorage.getStore(); // Will return a Map+  someAsyncOperation(() => {+    asyncLocalStorage.getStore(); // Will return the same Map+  });+});+asyncLocalStorage.getStore(); // Will return undefined+```++### asyncLocalStorage.exit(callback\[, ...args\])+<!-- YAML+added: REPLACEME+-->++* `callback` {Function}+* `...args` {any}++Calling `asyncLocalStorage.exit(callback)` will create a new asynchronous+context.+Within the callback function and the asynchronous operations from the callback,+`asyncLocalStorage.getStore()` will return `undefined`.+The callback will be ran asynchronously.++If an error is thrown by the callback function. It won't be caught by a+a `try/catch` block as the callback is ran in a new asynchronous resource.+Also, the stacktrace will be impacted by the asynchronous call.++Optionally, arguments can be passed to the function, they will be passed to+the callback function.++#### example+```js+asyncLocalStorage.run(() => {+  asyncLocalStorage.getStore(); // Will return a Map+  asyncLocalStorage.exit(() => {+    asyncLocalStorage.getStore(); // Will return undefined+  });+  asyncLocalStorage.getStore(); // Will return the same Map+});+```++### asyncLocalStorage.runSyncAndReturn(callback\[, ...args\])+<!-- YAML+added: REPLACEME+-->++* `callback` {Function}+* `...args` {any}++This methods runs a function synchronously within a context and return its+return value. The store is not accessible outside of the callback function or+the asynchronous operations created within the callback.++If the callback function throws an error, it will be thrown by+`runSyncAndReturn` too. The stacktrace will not be impacted by this call and+the context will be excited.++Optionally, arguments can be passed to the function, they will be passed to+the callback function.++#### example+```js+try {+  asyncLocalStorage.runSyncAndReturn(() => {+    asyncLocalStorage.getStore(); // Will return a Map+    throw new Error();+  });+} catch (e) {+  asyncLocalStorage.getStore(); // Will return undefined
  asyncLocalStorage.getStore(); // Returns undefined
vdeturckheim

comment created time in 12 days

Pull request review commentnodejs/node

async-hooks: introduce async-storage API

 for (let i = 0; i < 10; i++) { } ``` +## Class: AsyncLocalStorage+<!-- YAML+added: REPLACEME+-->++This class is used to create asynchronous state within callbacks and promise+chains. It allows storing data throughout the lifetime of a web request+or any other asynchronous duration. It is similar to thread local storage+in other languages.++The following example builds a logger that will always know the current HTTP+request and uses it to display enhanced logs without needing to explicitly+provide the current HTTP request to it.++```js+const { AsyncLocalStorage } = require('async_hooks');+const http = require('http');++const kReq = 'CURRENT_REQUEST';+const asyncLocalStorage = new AsyncLocalStorage();++function log(...args) {+  const store = asyncLocalStorage.getStore();+  // Make sure the store exists and it contains a request.+  if (store && store.has(kReq)) {+    const req = store.get(kReq);+    // Prints `GET /items ERR could not do something+    console.log(req.method, req.url, ...args);+  } else {+    console.log(...args);+  }+}++http.createServer((request, response) => {+  asyncLocalStorage.run(() => {+    const store = asyncLocalStorage.getStore();+    store.set(kReq, request);+    someAsyncOperation((err, result) => {+      if (err) {+        log('ERR', err.message);+      }+    });+  });+})+.listen(8080);+```++When having multiple instance of `AsyncLocalStorage`, they are independent+from each others. It is safe to instantiate this class multiple times.++### new AsyncLocalStorage()+<!-- YAML+added: REPLACEME+-->++* Returns: {Object}++Creates a new instance of `AsyncContext`. Storage is only provided within a+`run` or a `runSyncAndReturn` method call.++### asyncLocalStorage.getStore()+<!-- YAML+added: REPLACEME+-->++* Returns: {Map}++This methods returns the current store.+If this method is called  outside of an asynchronous context initialized by+calling `asyncLocalStorage.run` or `asyncLocalStorage.runAndReturn`, it will+return `undefined`.++### asyncLocalStorage.run(callback\[, ...args\])+<!-- YAML+added: REPLACEME+-->++* `callback` {Function}+* `...args` {any}++Calling `asyncLocalStorage.run(callback)` will create a new asynchronous+context.+Within the callback function and the asynchronous operations from the callback,+`asyncLocalStorage.getStore()` will return an instance of `Map` known as+"the store". This store will be persistent through the following+asynchronous calls.++The callback will be ran asynchronously.++If an error is thrown by the callback function. It won't be caught by a+a `try/catch` block as the callback is ran in a new asynchronous resource.+Also, the stacktrace will be impacted by the asynchronous call.++Optionally, arguments can be passed to the function, they will be passed to+the callback function.++#### example+```js+asyncLocalStorage.run(() => {+  asyncLocalStorage.getStore(); // Will return a Map+  someAsyncOperation(() => {+    asyncLocalStorage.getStore(); // Will return the same Map+  });+});+asyncLocalStorage.getStore(); // Will return undefined+```++### asyncLocalStorage.exit(callback\[, ...args\])+<!-- YAML+added: REPLACEME+-->++* `callback` {Function}+* `...args` {any}++Calling `asyncLocalStorage.exit(callback)` will create a new asynchronous+context.+Within the callback function and the asynchronous operations from the callback,+`asyncLocalStorage.getStore()` will return `undefined`.+The callback will be ran asynchronously.++If an error is thrown by the callback function. It won't be caught by a+a `try/catch` block as the callback is ran in a new asynchronous resource.+Also, the stacktrace will be impacted by the asynchronous call.++Optionally, arguments can be passed to the function, they will be passed to+the callback function.++#### example+```js+asyncLocalStorage.run(() => {+  asyncLocalStorage.getStore(); // Will return a Map+  asyncLocalStorage.exit(() => {+    asyncLocalStorage.getStore(); // Will return undefined+  });+  asyncLocalStorage.getStore(); // Will return the same Map+});+```++### asyncLocalStorage.runSyncAndReturn(callback\[, ...args\])+<!-- YAML+added: REPLACEME+-->++* `callback` {Function}+* `...args` {any}++This methods runs a function synchronously within a context and return its+return value. The store is not accessible outside of the callback function or+the asynchronous operations created within the callback.++If the callback function throws an error, it will be thrown by+`runSyncAndReturn` too. The stacktrace will not be impacted by this call and+the context will be excited.++Optionally, arguments can be passed to the function, they will be passed to+the callback function.++#### example
Example:

vdeturckheim

comment created time in 12 days

Pull request review commentnodejs/node

async-hooks: introduce async-storage API

 for (let i = 0; i < 10; i++) { } ``` +## Class: AsyncLocalStorage+<!-- YAML+added: REPLACEME+-->++This class is used to create asynchronous state within callbacks and promise+chains. It allows storing data throughout the lifetime of a web request+or any other asynchronous duration. It is similar to thread local storage+in other languages.++The following example builds a logger that will always know the current HTTP+request and uses it to display enhanced logs without needing to explicitly+provide the current HTTP request to it.++```js+const { AsyncLocalStorage } = require('async_hooks');+const http = require('http');++const kReq = 'CURRENT_REQUEST';+const asyncLocalStorage = new AsyncLocalStorage();++function log(...args) {+  const store = asyncLocalStorage.getStore();+  // Make sure the store exists and it contains a request.+  if (store && store.has(kReq)) {+    const req = store.get(kReq);+    // Prints `GET /items ERR could not do something+    console.log(req.method, req.url, ...args);+  } else {+    console.log(...args);+  }+}++http.createServer((request, response) => {+  asyncLocalStorage.run(() => {+    const store = asyncLocalStorage.getStore();+    store.set(kReq, request);+    someAsyncOperation((err, result) => {+      if (err) {+        log('ERR', err.message);+      }+    });+  });+})+.listen(8080);+```++When having multiple instance of `AsyncLocalStorage`, they are independent+from each others. It is safe to instantiate this class multiple times.++### new AsyncLocalStorage()+<!-- YAML+added: REPLACEME+-->++* Returns: {Object}++Creates a new instance of `AsyncContext`. Storage is only provided within a+`run` or a `runSyncAndReturn` method call.++### asyncLocalStorage.getStore()+<!-- YAML+added: REPLACEME+-->++* Returns: {Map}++This methods returns the current store.+If this method is called  outside of an asynchronous context initialized by+calling `asyncLocalStorage.run` or `asyncLocalStorage.runAndReturn`, it will+return `undefined`.++### asyncLocalStorage.run(callback\[, ...args\])+<!-- YAML+added: REPLACEME+-->++* `callback` {Function}+* `...args` {any}++Calling `asyncLocalStorage.run(callback)` will create a new asynchronous+context.+Within the callback function and the asynchronous operations from the callback,+`asyncLocalStorage.getStore()` will return an instance of `Map` known as+"the store". This store will be persistent through the following+asynchronous calls.++The callback will be ran asynchronously.++If an error is thrown by the callback function. It won't be caught by a+a `try/catch` block as the callback is ran in a new asynchronous resource.+Also, the stacktrace will be impacted by the asynchronous call.++Optionally, arguments can be passed to the function, they will be passed to+the callback function.++#### example+```js+asyncLocalStorage.run(() => {+  asyncLocalStorage.getStore(); // Will return a Map+  someAsyncOperation(() => {+    asyncLocalStorage.getStore(); // Will return the same Map+  });+});+asyncLocalStorage.getStore(); // Will return undefined+```++### asyncLocalStorage.exit(callback\[, ...args\])
### `asyncLocalStorage.exit(callback[, ...args])`
vdeturckheim

comment created time in 12 days

Pull request review commentnodejs/node

async-hooks: introduce async-storage API

 for (let i = 0; i < 10; i++) { } ``` +## Class: AsyncLocalStorage+<!-- YAML+added: REPLACEME+-->++This class is used to create asynchronous state within callbacks and promise+chains. It allows storing data throughout the lifetime of a web request+or any other asynchronous duration. It is similar to thread local storage+in other languages.++The following example builds a logger that will always know the current HTTP+request and uses it to display enhanced logs without needing to explicitly+provide the current HTTP request to it.++```js+const { AsyncLocalStorage } = require('async_hooks');+const http = require('http');++const kReq = 'CURRENT_REQUEST';+const asyncLocalStorage = new AsyncLocalStorage();++function log(...args) {+  const store = asyncLocalStorage.getStore();+  // Make sure the store exists and it contains a request.+  if (store && store.has(kReq)) {+    const req = store.get(kReq);+    // Prints `GET /items ERR could not do something+    console.log(req.method, req.url, ...args);+  } else {+    console.log(...args);+  }+}++http.createServer((request, response) => {+  asyncLocalStorage.run(() => {+    const store = asyncLocalStorage.getStore();+    store.set(kReq, request);+    someAsyncOperation((err, result) => {+      if (err) {+        log('ERR', err.message);+      }+    });+  });+})+.listen(8080);+```++When having multiple instance of `AsyncLocalStorage`, they are independent+from each others. It is safe to instantiate this class multiple times.++### new AsyncLocalStorage()+<!-- YAML+added: REPLACEME+-->++* Returns: {Object}
vdeturckheim

comment created time in 12 days

Pull request review commentnodejs/node

async-hooks: introduce async-storage API

 for (let i = 0; i < 10; i++) { } ``` +## Class: AsyncLocalStorage+<!-- YAML+added: REPLACEME+-->++This class is used to create asynchronous state within callbacks and promise+chains. It allows storing data throughout the lifetime of a web request+or any other asynchronous duration. It is similar to thread local storage+in other languages.++The following example builds a logger that will always know the current HTTP+request and uses it to display enhanced logs without needing to explicitly+provide the current HTTP request to it.++```js+const { AsyncLocalStorage } = require('async_hooks');+const http = require('http');++const kReq = 'CURRENT_REQUEST';+const asyncLocalStorage = new AsyncLocalStorage();++function log(...args) {+  const store = asyncLocalStorage.getStore();+  // Make sure the store exists and it contains a request.+  if (store && store.has(kReq)) {+    const req = store.get(kReq);+    // Prints `GET /items ERR could not do something+    console.log(req.method, req.url, ...args);+  } else {+    console.log(...args);+  }+}++http.createServer((request, response) => {+  asyncLocalStorage.run(() => {+    const store = asyncLocalStorage.getStore();+    store.set(kReq, request);+    someAsyncOperation((err, result) => {+      if (err) {+        log('ERR', err.message);+      }+    });+  });+})+.listen(8080);+```++When having multiple instance of `AsyncLocalStorage`, they are independent+from each others. It is safe to instantiate this class multiple times.++### new AsyncLocalStorage()+<!-- YAML+added: REPLACEME+-->++* Returns: {Object}++Creates a new instance of `AsyncContext`. Storage is only provided within a+`run` or a `runSyncAndReturn` method call.++### asyncLocalStorage.getStore()+<!-- YAML+added: REPLACEME+-->++* Returns: {Map}++This methods returns the current store.+If this method is called  outside of an asynchronous context initialized by+calling `asyncLocalStorage.run` or `asyncLocalStorage.runAndReturn`, it will+return `undefined`.++### asyncLocalStorage.run(callback\[, ...args\])
### `asyncLocalStorage.run(callback[, ...args])`
vdeturckheim

comment created time in 12 days

Pull request review commentnodejs/node

async-hooks: introduce async-storage API

 for (let i = 0; i < 10; i++) { } ``` +## Class: AsyncLocalStorage+<!-- YAML+added: REPLACEME+-->++This class is used to create asynchronous state within callbacks and promise+chains. It allows storing data throughout the lifetime of a web request+or any other asynchronous duration. It is similar to thread local storage+in other languages.++The following example builds a logger that will always know the current HTTP+request and uses it to display enhanced logs without needing to explicitly+provide the current HTTP request to it.++```js+const { AsyncLocalStorage } = require('async_hooks');+const http = require('http');++const kReq = 'CURRENT_REQUEST';+const asyncLocalStorage = new AsyncLocalStorage();++function log(...args) {+  const store = asyncLocalStorage.getStore();+  // Make sure the store exists and it contains a request.+  if (store && store.has(kReq)) {+    const req = store.get(kReq);+    // Prints `GET /items ERR could not do something+    console.log(req.method, req.url, ...args);+  } else {+    console.log(...args);+  }+}++http.createServer((request, response) => {+  asyncLocalStorage.run(() => {+    const store = asyncLocalStorage.getStore();+    store.set(kReq, request);+    someAsyncOperation((err, result) => {+      if (err) {+        log('ERR', err.message);+      }+    });+  });+})+.listen(8080);+```++When having multiple instance of `AsyncLocalStorage`, they are independent+from each others. It is safe to instantiate this class multiple times.++### new AsyncLocalStorage()+<!-- YAML+added: REPLACEME+-->++* Returns: {Object}++Creates a new instance of `AsyncContext`. Storage is only provided within a+`run` or a `runSyncAndReturn` method call.++### asyncLocalStorage.getStore()+<!-- YAML+added: REPLACEME+-->++* Returns: {Map}++This methods returns the current store.+If this method is called  outside of an asynchronous context initialized by+calling `asyncLocalStorage.run` or `asyncLocalStorage.runAndReturn`, it will+return `undefined`.++### asyncLocalStorage.run(callback\[, ...args\])+<!-- YAML+added: REPLACEME+-->++* `callback` {Function}+* `...args` {any}++Calling `asyncLocalStorage.run(callback)` will create a new asynchronous+context.+Within the callback function and the asynchronous operations from the callback,+`asyncLocalStorage.getStore()` will return an instance of `Map` known as+"the store". This store will be persistent through the following+asynchronous calls.++The callback will be ran asynchronously.++If an error is thrown by the callback function. It won't be caught by a+a `try/catch` block as the callback is ran in a new asynchronous resource.+Also, the stacktrace will be impacted by the asynchronous call.++Optionally, arguments can be passed to the function, they will be passed to+the callback function.++#### example+```js+asyncLocalStorage.run(() => {+  asyncLocalStorage.getStore(); // Will return a Map+  someAsyncOperation(() => {+    asyncLocalStorage.getStore(); // Will return the same Map+  });+});+asyncLocalStorage.getStore(); // Will return undefined+```++### asyncLocalStorage.exit(callback\[, ...args\])+<!-- YAML+added: REPLACEME+-->++* `callback` {Function}+* `...args` {any}++Calling `asyncLocalStorage.exit(callback)` will create a new asynchronous+context.+Within the callback function and the asynchronous operations from the callback,+`asyncLocalStorage.getStore()` will return `undefined`.+The callback will be ran asynchronously.++If an error is thrown by the callback function. It won't be caught by a+a `try/catch` block as the callback is ran in a new asynchronous resource.+Also, the stacktrace will be impacted by the asynchronous call.++Optionally, arguments can be passed to the function, they will be passed to
Optionally, arguments can be passed to the function. They will be passed to
vdeturckheim

comment created time in 12 days

Pull request review commentnodejs/node

async-hooks: introduce async-storage API

 for (let i = 0; i < 10; i++) { } ``` +## Class: AsyncLocalStorage+<!-- YAML+added: REPLACEME+-->++This class is used to create asynchronous state within callbacks and promise+chains. It allows storing data throughout the lifetime of a web request+or any other asynchronous duration. It is similar to thread local storage+in other languages.++The following example builds a logger that will always know the current HTTP+request and uses it to display enhanced logs without needing to explicitly+provide the current HTTP request to it.++```js+const { AsyncLocalStorage } = require('async_hooks');+const http = require('http');++const kReq = 'CURRENT_REQUEST';+const asyncLocalStorage = new AsyncLocalStorage();++function log(...args) {+  const store = asyncLocalStorage.getStore();+  // Make sure the store exists and it contains a request.+  if (store && store.has(kReq)) {+    const req = store.get(kReq);+    // Prints `GET /items ERR could not do something+    console.log(req.method, req.url, ...args);+  } else {+    console.log(...args);+  }+}++http.createServer((request, response) => {+  asyncLocalStorage.run(() => {+    const store = asyncLocalStorage.getStore();+    store.set(kReq, request);+    someAsyncOperation((err, result) => {+      if (err) {+        log('ERR', err.message);+      }+    });+  });+})+.listen(8080);+```++When having multiple instance of `AsyncLocalStorage`, they are independent+from each others. It is safe to instantiate this class multiple times.++### new AsyncLocalStorage()+<!-- YAML+added: REPLACEME+-->++* Returns: {Object}++Creates a new instance of `AsyncContext`. Storage is only provided within a+`run` or a `runSyncAndReturn` method call.++### asyncLocalStorage.getStore()+<!-- YAML+added: REPLACEME+-->++* Returns: {Map}++This methods returns the current store.+If this method is called  outside of an asynchronous context initialized by+calling `asyncLocalStorage.run` or `asyncLocalStorage.runAndReturn`, it will+return `undefined`.++### asyncLocalStorage.run(callback\[, ...args\])+<!-- YAML+added: REPLACEME+-->++* `callback` {Function}+* `...args` {any}++Calling `asyncLocalStorage.run(callback)` will create a new asynchronous+context.+Within the callback function and the asynchronous operations from the callback,+`asyncLocalStorage.getStore()` will return an instance of `Map` known as+"the store". This store will be persistent through the following+asynchronous calls.++The callback will be ran asynchronously.++If an error is thrown by the callback function. It won't be caught by a+a `try/catch` block as the callback is ran in a new asynchronous resource.+Also, the stacktrace will be impacted by the asynchronous call.++Optionally, arguments can be passed to the function, they will be passed to+the callback function.++#### example+```js+asyncLocalStorage.run(() => {+  asyncLocalStorage.getStore(); // Will return a Map+  someAsyncOperation(() => {+    asyncLocalStorage.getStore(); // Will return the same Map+  });+});+asyncLocalStorage.getStore(); // Will return undefined+```++### asyncLocalStorage.exit(callback\[, ...args\])+<!-- YAML+added: REPLACEME+-->++* `callback` {Function}+* `...args` {any}++Calling `asyncLocalStorage.exit(callback)` will create a new asynchronous+context.+Within the callback function and the asynchronous operations from the callback,+`asyncLocalStorage.getStore()` will return `undefined`.+The callback will be ran asynchronously.++If an error is thrown by the callback function. It won't be caught by a+a `try/catch` block as the callback is ran in a new asynchronous resource.+Also, the stacktrace will be impacted by the asynchronous call.++Optionally, arguments can be passed to the function, they will be passed to+the callback function.++#### example+```js+asyncLocalStorage.run(() => {+  asyncLocalStorage.getStore(); // Will return a Map+  asyncLocalStorage.exit(() => {+    asyncLocalStorage.getStore(); // Will return undefined+  });+  asyncLocalStorage.getStore(); // Will return the same Map+});+```++### asyncLocalStorage.runSyncAndReturn(callback\[, ...args\])+<!-- YAML+added: REPLACEME+-->++* `callback` {Function}+* `...args` {any}++This methods runs a function synchronously within a context and return its+return value. The store is not accessible outside of the callback function or+the asynchronous operations created within the callback.++If the callback function throws an error, it will be thrown by+`runSyncAndReturn` too. The stacktrace will not be impacted by this call and+the context will be excited.++Optionally, arguments can be passed to the function, they will be passed to+the callback function.++#### example+```js+try {+  asyncLocalStorage.runSyncAndReturn(() => {+    asyncLocalStorage.getStore(); // Will return a Map+    throw new Error();+  });+} catch (e) {+  asyncLocalStorage.getStore(); // Will return undefined+  // The error will be caught here+}+```++### asyncLocalStorage.exitSyncAndReturn(callback\[, ...args\])
### `asyncLocalStorage.exitSyncAndReturn(callback[, ...args])`
vdeturckheim

comment created time in 12 days

Pull request review commentnodejs/node

async-hooks: introduce async-storage API

 for (let i = 0; i < 10; i++) { } ``` +## Class: AsyncLocalStorage+<!-- YAML+added: REPLACEME+-->++This class is used to create asynchronous state within callbacks and promise+chains. It allows storing data throughout the lifetime of a web request+or any other asynchronous duration. It is similar to thread local storage+in other languages.++The following example builds a logger that will always know the current HTTP+request and uses it to display enhanced logs without needing to explicitly+provide the current HTTP request to it.++```js+const { AsyncLocalStorage } = require('async_hooks');+const http = require('http');++const kReq = 'CURRENT_REQUEST';+const asyncLocalStorage = new AsyncLocalStorage();++function log(...args) {+  const store = asyncLocalStorage.getStore();+  // Make sure the store exists and it contains a request.+  if (store && store.has(kReq)) {+    const req = store.get(kReq);+    // Prints `GET /items ERR could not do something+    console.log(req.method, req.url, ...args);+  } else {+    console.log(...args);+  }+}++http.createServer((request, response) => {+  asyncLocalStorage.run(() => {+    const store = asyncLocalStorage.getStore();+    store.set(kReq, request);+    someAsyncOperation((err, result) => {+      if (err) {+        log('ERR', err.message);+      }+    });+  });+})+.listen(8080);+```++When having multiple instance of `AsyncLocalStorage`, they are independent+from each others. It is safe to instantiate this class multiple times.++### new AsyncLocalStorage()+<!-- YAML+added: REPLACEME+-->++* Returns: {Object}++Creates a new instance of `AsyncContext`. Storage is only provided within a+`run` or a `runSyncAndReturn` method call.++### asyncLocalStorage.getStore()+<!-- YAML+added: REPLACEME+-->++* Returns: {Map}++This methods returns the current store.+If this method is called  outside of an asynchronous context initialized by+calling `asyncLocalStorage.run` or `asyncLocalStorage.runAndReturn`, it will+return `undefined`.++### asyncLocalStorage.run(callback\[, ...args\])+<!-- YAML+added: REPLACEME+-->++* `callback` {Function}+* `...args` {any}++Calling `asyncLocalStorage.run(callback)` will create a new asynchronous+context.+Within the callback function and the asynchronous operations from the callback,+`asyncLocalStorage.getStore()` will return an instance of `Map` known as+"the store". This store will be persistent through the following+asynchronous calls.++The callback will be ran asynchronously.++If an error is thrown by the callback function. It won't be caught by a+a `try/catch` block as the callback is ran in a new asynchronous resource.+Also, the stacktrace will be impacted by the asynchronous call.++Optionally, arguments can be passed to the function, they will be passed to+the callback function.++#### example+```js+asyncLocalStorage.run(() => {+  asyncLocalStorage.getStore(); // Will return a Map+  someAsyncOperation(() => {+    asyncLocalStorage.getStore(); // Will return the same Map
    asyncLocalStorage.getStore(); // Returns the same Map
vdeturckheim

comment created time in 12 days

Pull request review commentnodejs/node

async-hooks: introduce async-storage API

 for (let i = 0; i < 10; i++) { } ``` +## Class: AsyncLocalStorage+<!-- YAML+added: REPLACEME+-->++This class is used to create asynchronous state within callbacks and promise+chains. It allows storing data throughout the lifetime of a web request+or any other asynchronous duration. It is similar to thread local storage+in other languages.++The following example builds a logger that will always know the current HTTP+request and uses it to display enhanced logs without needing to explicitly+provide the current HTTP request to it.++```js+const { AsyncLocalStorage } = require('async_hooks');+const http = require('http');++const kReq = 'CURRENT_REQUEST';+const asyncLocalStorage = new AsyncLocalStorage();++function log(...args) {+  const store = asyncLocalStorage.getStore();+  // Make sure the store exists and it contains a request.+  if (store && store.has(kReq)) {+    const req = store.get(kReq);+    // Prints `GET /items ERR could not do something+    console.log(req.method, req.url, ...args);+  } else {+    console.log(...args);+  }+}++http.createServer((request, response) => {+  asyncLocalStorage.run(() => {+    const store = asyncLocalStorage.getStore();+    store.set(kReq, request);+    someAsyncOperation((err, result) => {+      if (err) {+        log('ERR', err.message);+      }+    });+  });+})+.listen(8080);+```++When having multiple instance of `AsyncLocalStorage`, they are independent+from each others. It is safe to instantiate this class multiple times.++### new AsyncLocalStorage()+<!-- YAML+added: REPLACEME+-->++* Returns: {Object}++Creates a new instance of `AsyncContext`. Storage is only provided within a+`run` or a `runSyncAndReturn` method call.++### asyncLocalStorage.getStore()+<!-- YAML+added: REPLACEME+-->++* Returns: {Map}++This methods returns the current store.+If this method is called  outside of an asynchronous context initialized by+calling `asyncLocalStorage.run` or `asyncLocalStorage.runAndReturn`, it will+return `undefined`.++### asyncLocalStorage.run(callback\[, ...args\])+<!-- YAML+added: REPLACEME+-->++* `callback` {Function}+* `...args` {any}++Calling `asyncLocalStorage.run(callback)` will create a new asynchronous+context.+Within the callback function and the asynchronous operations from the callback,+`asyncLocalStorage.getStore()` will return an instance of `Map` known as+"the store". This store will be persistent through the following+asynchronous calls.++The callback will be ran asynchronously.++If an error is thrown by the callback function. It won't be caught by a+a `try/catch` block as the callback is ran in a new asynchronous resource.+Also, the stacktrace will be impacted by the asynchronous call.++Optionally, arguments can be passed to the function, they will be passed to
Optionally, arguments can be passed to the function. They will be passed to
vdeturckheim

comment created time in 12 days

Pull request review commentnodejs/node

async-hooks: introduce async-storage API

 for (let i = 0; i < 10; i++) { } ``` +## Class: AsyncLocalStorage+<!-- YAML+added: REPLACEME+-->++This class is used to create asynchronous state within callbacks and promise+chains. It allows storing data throughout the lifetime of a web request+or any other asynchronous duration. It is similar to thread local storage+in other languages.++The following example builds a logger that will always know the current HTTP+request and uses it to display enhanced logs without needing to explicitly+provide the current HTTP request to it.++```js+const { AsyncLocalStorage } = require('async_hooks');+const http = require('http');++const kReq = 'CURRENT_REQUEST';+const asyncLocalStorage = new AsyncLocalStorage();++function log(...args) {+  const store = asyncLocalStorage.getStore();+  // Make sure the store exists and it contains a request.+  if (store && store.has(kReq)) {+    const req = store.get(kReq);+    // Prints `GET /items ERR could not do something+    console.log(req.method, req.url, ...args);+  } else {+    console.log(...args);+  }+}++http.createServer((request, response) => {+  asyncLocalStorage.run(() => {+    const store = asyncLocalStorage.getStore();+    store.set(kReq, request);+    someAsyncOperation((err, result) => {+      if (err) {+        log('ERR', err.message);+      }+    });+  });+})+.listen(8080);+```++When having multiple instance of `AsyncLocalStorage`, they are independent+from each others. It is safe to instantiate this class multiple times.++### new AsyncLocalStorage()+<!-- YAML+added: REPLACEME+-->++* Returns: {Object}++Creates a new instance of `AsyncContext`. Storage is only provided within a+`run` or a `runSyncAndReturn` method call.++### asyncLocalStorage.getStore()+<!-- YAML+added: REPLACEME+-->++* Returns: {Map}++This methods returns the current store.+If this method is called  outside of an asynchronous context initialized by+calling `asyncLocalStorage.run` or `asyncLocalStorage.runAndReturn`, it will+return `undefined`.++### asyncLocalStorage.run(callback\[, ...args\])+<!-- YAML+added: REPLACEME+-->++* `callback` {Function}+* `...args` {any}++Calling `asyncLocalStorage.run(callback)` will create a new asynchronous+context.+Within the callback function and the asynchronous operations from the callback,+`asyncLocalStorage.getStore()` will return an instance of `Map` known as+"the store". This store will be persistent through the following+asynchronous calls.++The callback will be ran asynchronously.++If an error is thrown by the callback function. It won't be caught by a+a `try/catch` block as the callback is ran in a new asynchronous resource.+Also, the stacktrace will be impacted by the asynchronous call.++Optionally, arguments can be passed to the function, they will be passed to+the callback function.++#### example+```js+asyncLocalStorage.run(() => {+  asyncLocalStorage.getStore(); // Will return a Map
  asyncLocalStorage.getStore(); // Returns a Map
vdeturckheim

comment created time in 12 days

Pull request review commentnodejs/node

async-hooks: introduce async-storage API

 for (let i = 0; i < 10; i++) { } ``` +## Class: AsyncLocalStorage+<!-- YAML+added: REPLACEME+-->++This class is used to create asynchronous state within callbacks and promise+chains. It allows storing data throughout the lifetime of a web request+or any other asynchronous duration. It is similar to thread local storage+in other languages.++The following example builds a logger that will always know the current HTTP+request and uses it to display enhanced logs without needing to explicitly+provide the current HTTP request to it.++```js+const { AsyncLocalStorage } = require('async_hooks');+const http = require('http');++const kReq = 'CURRENT_REQUEST';+const asyncLocalStorage = new AsyncLocalStorage();++function log(...args) {+  const store = asyncLocalStorage.getStore();+  // Make sure the store exists and it contains a request.+  if (store && store.has(kReq)) {+    const req = store.get(kReq);+    // Prints `GET /items ERR could not do something+    console.log(req.method, req.url, ...args);+  } else {+    console.log(...args);+  }+}++http.createServer((request, response) => {+  asyncLocalStorage.run(() => {+    const store = asyncLocalStorage.getStore();+    store.set(kReq, request);+    someAsyncOperation((err, result) => {+      if (err) {+        log('ERR', err.message);+      }+    });+  });+})+.listen(8080);+```++When having multiple instance of `AsyncLocalStorage`, they are independent+from each others. It is safe to instantiate this class multiple times.++### new AsyncLocalStorage()+<!-- YAML+added: REPLACEME+-->++* Returns: {Object}++Creates a new instance of `AsyncContext`. Storage is only provided within a+`run` or a `runSyncAndReturn` method call.++### asyncLocalStorage.getStore()+<!-- YAML+added: REPLACEME+-->++* Returns: {Map}++This methods returns the current store.+If this method is called  outside of an asynchronous context initialized by+calling `asyncLocalStorage.run` or `asyncLocalStorage.runAndReturn`, it will+return `undefined`.++### asyncLocalStorage.run(callback\[, ...args\])+<!-- YAML+added: REPLACEME+-->++* `callback` {Function}+* `...args` {any}++Calling `asyncLocalStorage.run(callback)` will create a new asynchronous+context.+Within the callback function and the asynchronous operations from the callback,+`asyncLocalStorage.getStore()` will return an instance of `Map` known as+"the store". This store will be persistent through the following+asynchronous calls.++The callback will be ran asynchronously.++If an error is thrown by the callback function. It won't be caught by a+a `try/catch` block as the callback is ran in a new asynchronous resource.+Also, the stacktrace will be impacted by the asynchronous call.++Optionally, arguments can be passed to the function, they will be passed to+the callback function.++#### example+```js+asyncLocalStorage.run(() => {+  asyncLocalStorage.getStore(); // Will return a Map+  someAsyncOperation(() => {+    asyncLocalStorage.getStore(); // Will return the same Map+  });+});+asyncLocalStorage.getStore(); // Will return undefined+```++### asyncLocalStorage.exit(callback\[, ...args\])+<!-- YAML+added: REPLACEME+-->++* `callback` {Function}+* `...args` {any}++Calling `asyncLocalStorage.exit(callback)` will create a new asynchronous+context.+Within the callback function and the asynchronous operations from the callback,+`asyncLocalStorage.getStore()` will return `undefined`.+The callback will be ran asynchronously.++If an error is thrown by the callback function. It won't be caught by a+a `try/catch` block as the callback is ran in a new asynchronous resource.+Also, the stacktrace will be impacted by the asynchronous call.++Optionally, arguments can be passed to the function, they will be passed to+the callback function.++#### example
Example:

vdeturckheim

comment created time in 12 days

Pull request review commentnodejs/node

async-hooks: introduce async-storage API

 for (let i = 0; i < 10; i++) { } ``` +## Class: AsyncLocalStorage+<!-- YAML+added: REPLACEME+-->++This class is used to create asynchronous state within callbacks and promise+chains. It allows storing data throughout the lifetime of a web request+or any other asynchronous duration. It is similar to thread local storage+in other languages.++The following example builds a logger that will always know the current HTTP+request and uses it to display enhanced logs without needing to explicitly+provide the current HTTP request to it.++```js+const { AsyncLocalStorage } = require('async_hooks');+const http = require('http');++const kReq = 'CURRENT_REQUEST';+const asyncLocalStorage = new AsyncLocalStorage();++function log(...args) {+  const store = asyncLocalStorage.getStore();+  // Make sure the store exists and it contains a request.+  if (store && store.has(kReq)) {+    const req = store.get(kReq);+    // Prints `GET /items ERR could not do something+    console.log(req.method, req.url, ...args);+  } else {+    console.log(...args);+  }+}++http.createServer((request, response) => {+  asyncLocalStorage.run(() => {+    const store = asyncLocalStorage.getStore();+    store.set(kReq, request);+    someAsyncOperation((err, result) => {+      if (err) {+        log('ERR', err.message);+      }+    });+  });+})+.listen(8080);+```++When having multiple instance of `AsyncLocalStorage`, they are independent+from each others. It is safe to instantiate this class multiple times.++### new AsyncLocalStorage()+<!-- YAML+added: REPLACEME+-->++* Returns: {Object}+
vdeturckheim

comment created time in 12 days

more