Skip to content

Commit a5bc00a

Browse files
committed
Revert "events: allow monitoring error events"
This reverts commit 5cb0de9.
1 parent 51fdd75 commit a5bc00a

File tree

3 files changed

+2
-69
lines changed

3 files changed

+2
-69
lines changed

doc/api/events.md

Lines changed: 0 additions & 25 deletions
Original file line numberDiff line numberDiff line change
@@ -155,18 +155,6 @@ myEmitter.emit('error', new Error('whoops!'));
155155
// Prints: whoops! there was an error
156156
```
157157

158-
It is possible to monitor `'error'` events without consuming the emitted error
159-
by installing a listener using the symbol `errorMonitor`.
160-
161-
```js
162-
const myEmitter = new MyEmitter();
163-
myEmitter.on(EventEmitter.errorMonitor, (err) => {
164-
MyMonitoringTool.log(err);
165-
});
166-
myEmitter.emit('error', new Error('whoops!'));
167-
// Still throws and crashes Node.js
168-
```
169-
170158
## Capture Rejections of Promises
171159

172160
> Stability: 1 - captureRejections is experimental.
@@ -360,19 +348,6 @@ the event emitter instance, the event’s name and the number of attached
360348
listeners, respectively.
361349
Its `name` property is set to `'MaxListenersExceededWarning'`.
362350

363-
### `EventEmitter.errorMonitor`
364-
<!-- YAML
365-
added: v12.16.0
366-
-->
367-
368-
This symbol shall be used to install a listener for only monitoring `'error'`
369-
events. Listeners installed using this symbol are called before the regular
370-
`'error'` listeners are called.
371-
372-
Installing a listener using this symbol does not change the behavior once an
373-
`'error'` event is emitted, therefore the process will still crash if no
374-
regular `'error'` listener is installed.
375-
376351
### `emitter.addListener(eventName, listener)`
377352
<!-- YAML
378353
added: v0.1.26

lib/events.js

Lines changed: 2 additions & 12 deletions
Original file line numberDiff line numberDiff line change
@@ -60,7 +60,6 @@ const {
6060
} = require('internal/util/inspect');
6161

6262
const kCapture = Symbol('kCapture');
63-
const kErrorMonitor = Symbol('events.errorMonitor');
6463

6564
function EventEmitter(opts) {
6665
EventEmitter.init.call(this, opts);
@@ -90,13 +89,6 @@ ObjectDefineProperty(EventEmitter, 'captureRejections', {
9089
enumerable: true
9190
});
9291

93-
ObjectDefineProperty(EventEmitter, 'errorMonitor', {
94-
value: kErrorMonitor,
95-
writable: false,
96-
configurable: true,
97-
enumerable: true
98-
});
99-
10092
// The default for captureRejections is false
10193
ObjectDefineProperty(EventEmitter.prototype, kCapture, {
10294
value: false,
@@ -270,11 +262,9 @@ EventEmitter.prototype.emit = function emit(type, ...args) {
270262
let doError = (type === 'error');
271263

272264
const events = this._events;
273-
if (events !== undefined) {
274-
if (doError && events[kErrorMonitor] !== undefined)
275-
this.emit(kErrorMonitor, ...args);
265+
if (events !== undefined)
276266
doError = (doError && events.error === undefined);
277-
} else if (!doError)
267+
else if (!doError)
278268
return false;
279269

280270
// If there is no 'error' event listener then throw.

test/parallel/test-event-emitter-error-monitor.js

Lines changed: 0 additions & 32 deletions
This file was deleted.

0 commit comments

Comments
 (0)