-
Notifications
You must be signed in to change notification settings - Fork 29.8k
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Fix an issue where error is never emitted on the original EventEmitter in situations where a listener for error does exist. Refactor to eliminate unnecessary try/catch/finally block. Backport-PR-URL: #18487 PR-URL: #17588 Refs: #17403 Reviewed-By: Ruben Bridgewater <[email protected]> Reviewed-By: James M Snell <[email protected]>
- Loading branch information
1 parent
28edc1d
commit 35471bc
Showing
2 changed files
with
40 additions
and
17 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,20 @@ | ||
'use strict'; | ||
|
||
const common = require('../common'); | ||
const assert = require('assert'); | ||
const domain = require('domain').create(); | ||
const EventEmitter = require('events'); | ||
|
||
domain.on('error', common.mustNotCall()); | ||
|
||
const ee = new EventEmitter(); | ||
|
||
const plainObject = { justAn: 'object' }; | ||
ee.once('error', common.mustCall((err) => { | ||
assert.deepStrictEqual(err, plainObject); | ||
})); | ||
ee.emit('error', plainObject); | ||
|
||
const err = new Error('test error'); | ||
ee.once('error', common.expectsError(err)); | ||
ee.emit('error', err); |