Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

events: graduate capturerejections to supported #41267

Merged
Merged
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
24 changes: 14 additions & 10 deletions doc/api/events.md
Original file line number Diff line number Diff line change
Expand Up @@ -173,8 +173,6 @@ myEmitter.emit('error', new Error('whoops!'));

## Capture rejections of promises

> Stability: 1 - captureRejections is experimental.

Using `async` functions with event handlers is problematic, because it
can lead to an unhandled rejection in case of a thrown exception:

Expand Down Expand Up @@ -741,10 +739,12 @@ emitter.emit('log');
added:
- v13.4.0
- v12.16.0
changes:
- version: REPLACEME
pr-url: https://github.com/nodejs/node/pull/41267
description: No longer experimental.
-->

> Stability: 1 - captureRejections is experimental.

* `err` Error
* `eventName` {string|symbol}
* `...args` {any}
Expand Down Expand Up @@ -1028,10 +1028,12 @@ foo().then(() => console.log('done'));
added:
- v13.4.0
- v12.16.0
changes:
- version: REPLACEME
pr-url: https://github.com/nodejs/node/pull/41267
description: No longer experimental.
-->

> Stability: 1 - captureRejections is experimental.

Value: {boolean}

Change the default `captureRejections` option on all new `EventEmitter` objects.
Expand All @@ -1040,12 +1042,14 @@ Change the default `captureRejections` option on all new `EventEmitter` objects.

<!-- YAML
added:
- v13.4.0
- v12.16.0
- v13.4.0
- v12.16.0
changes:
- version: REPLACEME
pr-url: https://github.com/nodejs/node/pull/41267
description: No longer experimental.
-->

> Stability: 1 - captureRejections is experimental.

Value: `Symbol.for('nodejs.rejection')`

See how to write a custom [rejection handler][rejection].
Expand Down