diff options
author | Benjamin Gruenbaum <benjamingr@gmail.com> | 2021-02-07 14:25:35 +0200 |
---|---|---|
committer | Benjamin Gruenbaum <benjamingr@gmail.com> | 2021-02-11 17:09:23 +0200 |
commit | cf5f6af8d68995abe28da236e5d16194fce76a75 (patch) | |
tree | 4de6cd12513d317466a431cc01fae6851ac55438 | |
parent | 295e766c2782d6d83e33004f7c2204c0a8d52655 (diff) | |
download | node-new-cf5f6af8d68995abe28da236e5d16194fce76a75.tar.gz |
doc: discourage error event
PR-URL: https://github.com/nodejs/node/pull/37264
Refs: https://github.com/nodejs/node/pull/37237
Reviewed-By: Anna Henningsen <anna@addaleax.net>
Reviewed-By: Matteo Collina <matteo.collina@gmail.com>
Reviewed-By: Rich Trott <rtrott@gmail.com>
-rw-r--r-- | doc/api/events.md | 19 |
1 files changed, 14 insertions, 5 deletions
diff --git a/doc/api/events.md b/doc/api/events.md index 571f2893a7..cd2d7fc613 100644 --- a/doc/api/events.md +++ b/doc/api/events.md @@ -1247,12 +1247,21 @@ target.addEventListener('foo', handler4, { once: true }); ### `EventTarget` error handling When a registered event listener throws (or returns a Promise that rejects), -by default the error is forwarded to the `process.on('error')` event -on `process.nextTick()`. Throwing within an event listener will *not* stop -the other registered handlers from being invoked. +by default the error is treated as an uncaught exception on +`process.nextTick()`. This means uncaught exceptions in `EventTarget`s will +terminate the Node.js process by default. -The `EventTarget` does not implement any special default handling for -`'error'` type events. +Throwing within an event listener will *not* stop the other registered handlers +from being invoked. + +The `EventTarget` does not implement any special default handling for `'error'` +type events like `EventEmitter`. + +Currently errors are first forwarded to the `process.on('error')` event +before reaching `process.on('uncaughtException')`. This behavior is +deprecated and will change in a future release to align `EventTarget` with +other Node.js APIs. Any code relying on the `process.on('error')` event should +be aligned with the new behavior. ### Class: `Event` <!-- YAML |