Skip to content

Commit 04625f9

Browse files
committed
doc: discourage error event
1 parent 907d6b6 commit 04625f9

File tree

1 file changed

+14
-5
lines changed

1 file changed

+14
-5
lines changed

doc/api/events.md

+14-5
Original file line numberDiff line numberDiff line change
@@ -1247,12 +1247,21 @@ target.addEventListener('foo', handler4, { once: true });
12471247
### `EventTarget` error handling
12481248

12491249
When a registered event listener throws (or returns a Promise that rejects),
1250-
by default the error is forwarded to the `process.on('error')` event
1251-
on `process.nextTick()`. Throwing within an event listener will *not* stop
1252-
the other registered handlers from being invoked.
1250+
by default the error is treated as an uncaught exception on
1251+
`process.nextTick()`. This means uncaught exceptions in `EventTarget`s will
1252+
terminate the Node.js process by default.
12531253

1254-
The `EventTarget` does not implement any special default handling for
1255-
`'error'` type events.
1254+
Throwing within an event listener will *not* stop the other registered handlers
1255+
from being invoked.
1256+
1257+
The `EventTarget` does not implement any special default handling for `'error'`
1258+
type events like `EventEmitter`.
1259+
1260+
Currently errors are first forwarded to the `process.on('error')` event
1261+
before reaching `process.on('uncaughtException')`. This behaviour is
1262+
deprecated and will change in a future release to align `EventTarget` with
1263+
other Node.js APIs. Any code relying on the `process.on('error')` event should
1264+
be aligned with the new behaviour.
12561265

12571266
### Class: `Event`
12581267
<!-- YAML

0 commit comments

Comments
 (0)