0
0
mirror of https://github.com/nodejs/node.git synced 2024-12-01 16:10:02 +01:00
nodejs/doc/api
Ali Ijaz Sheikh 523a1550a3 async_hooks: deprecate unsafe emit{Before,After}
The emit{Before,After} APIs in AsyncResource are problematic.

* emit{Before,After} are named to suggest that the only thing they do
  is emit the before and after hooks. However, they in fact, mutate
  the current execution context.
* They must be properly nested. Failure to do so by user code leads
  to catastrophic (unrecoverable) exceptions. It is very easy for the
  users to forget that they must be using a try/finally block around
  the code that must be surrounded by these operations. Even the
  example provided in the official docs makes this mistake. Failing
  to use a finally can lead to a catastrophic crash if the callback
  ends up throwing.

This change provides a safer `runInAsyncScope` API as an alternative
and deprecates emit{Before,After}.

PR-URL: https://github.com/nodejs/node/pull/18513
Reviewed-By: James M Snell <jasnell@gmail.com>
Reviewed-By: Anna Henningsen <anna@addaleax.net>
Reviewed-By: Andreas Madsen <amwebdk@gmail.com>
2018-02-09 13:03:34 -08:00
..
_toc.md
addons.md doc: remove **Note:** tags 2018-02-08 11:57:14 -05:00
all.md
assert.md doc: fix links in YAML metadata of assert.md 2018-02-09 17:15:47 +02:00
async_hooks.md async_hooks: deprecate unsafe emit{Before,After} 2018-02-09 13:03:34 -08:00
buffer.md doc: remove **Note:** tags 2018-02-08 11:57:14 -05:00
child_process.md doc: remove **Note:** tags 2018-02-08 11:57:14 -05:00
cli.md doc: remove **Note:** tags 2018-02-08 11:57:14 -05:00
cluster.md doc: remove **Note:** tags 2018-02-08 11:57:14 -05:00
console.md doc: remove **Note:** tags 2018-02-08 11:57:14 -05:00
crypto.md doc: add missing meta for createCipheriv 2018-02-09 01:26:39 +01:00
debugger.md
deprecations.md async_hooks: deprecate unsafe emit{Before,After} 2018-02-09 13:03:34 -08:00
dgram.md
dns.md
documentation.md doc: remove **Note:** tags 2018-02-08 11:57:14 -05:00
domain.md
errors.md doc: remove **Note:** tags 2018-02-08 11:57:14 -05:00
esm.md
events.md
fs.md doc: fix arg definition in fs 2018-02-09 11:28:16 -05:00
globals.md
http2.md http2: add req and res options to server creation 2018-02-09 12:54:18 -05:00
http.md doc: remove **Note:** tags 2018-02-08 11:57:14 -05:00
https.md doc: fix link in https.md 2018-02-08 01:30:42 +02:00
index.md
inspector.md
intl.md doc: remove **Note:** tags 2018-02-08 11:57:14 -05:00
modules.md doc: remove **Note:** tags 2018-02-08 11:57:14 -05:00
n-api.md doc: remove **Note:** tags 2018-02-08 11:57:14 -05:00
net.md doc: remove **Note:** tags 2018-02-08 11:57:14 -05:00
os.md doc: remove **Note:** tags 2018-02-08 11:57:14 -05:00
path.md doc: remove **Note:** tags 2018-02-08 11:57:14 -05:00
perf_hooks.md
process.md doc: remove **Note:** tags 2018-02-08 11:57:14 -05:00
punycode.md doc: remove **Note:** tags 2018-02-08 11:57:14 -05:00
querystring.md doc: remove **Note:** tags 2018-02-08 11:57:14 -05:00
readline.md doc: remove **Note:** tags 2018-02-08 11:57:14 -05:00
repl.md
stream.md doc: remove **Note:** tags 2018-02-08 11:57:14 -05:00
string_decoder.md
synopsis.md
timers.md doc: remove **Note:** tags 2018-02-08 11:57:14 -05:00
tls.md doc: remove **Note:** tags 2018-02-08 11:57:14 -05:00
tracing.md
tty.md
url.md doc: remove **Note:** tags 2018-02-08 11:57:14 -05:00
util.md doc: remove **Note:** tags 2018-02-08 11:57:14 -05:00
v8.md doc: remove **Note:** tags 2018-02-08 11:57:14 -05:00
vm.md doc: remove **Note:** tags 2018-02-08 11:57:14 -05:00
zlib.md doc: remove **Note:** tags 2018-02-08 11:57:14 -05:00