21
21
22
22
'use strict' ;
23
23
24
- var domain ;
25
24
var spliceOne ;
26
25
27
26
function EventEmitter ( ) {
@@ -32,9 +31,6 @@ module.exports = EventEmitter;
32
31
// Backwards-compat with node 0.10.x
33
32
EventEmitter . EventEmitter = EventEmitter ;
34
33
35
- EventEmitter . usingDomains = false ;
36
-
37
- EventEmitter . prototype . domain = undefined ;
38
34
EventEmitter . prototype . _events = undefined ;
39
35
EventEmitter . prototype . _maxListeners = undefined ;
40
36
@@ -66,14 +62,6 @@ Object.defineProperty(EventEmitter, 'defaultMaxListeners', {
66
62
} ) ;
67
63
68
64
EventEmitter . init = function ( ) {
69
- this . domain = null ;
70
- if ( EventEmitter . usingDomains ) {
71
- // if there is an active domain, then attach to it.
72
- domain = domain || require ( 'domain' ) ;
73
- if ( domain . active && ! ( this instanceof domain . Domain ) ) {
74
- this . domain = domain . active ;
75
- }
76
- }
77
65
78
66
if ( this . _events === undefined ||
79
67
this . _events === Object . getPrototypeOf ( this ) . _events ) {
@@ -114,47 +102,26 @@ EventEmitter.prototype.emit = function emit(type, ...args) {
114
102
else if ( ! doError )
115
103
return false ;
116
104
117
- const domain = this . domain ;
118
-
119
105
// If there is no 'error' event listener then throw.
120
106
if ( doError ) {
121
107
let er ;
122
108
if ( args . length > 0 )
123
109
er = args [ 0 ] ;
124
- if ( domain !== null && domain !== undefined ) {
125
- if ( ! er ) {
126
- const errors = lazyErrors ( ) ;
127
- er = new errors . Error ( 'ERR_UNHANDLED_ERROR' ) ;
128
- }
129
- if ( typeof er === 'object' && er !== null ) {
130
- er . domainEmitter = this ;
131
- er . domain = domain ;
132
- er . domainThrown = false ;
133
- }
134
- domain . emit ( 'error' , er ) ;
135
- } else if ( er instanceof Error ) {
110
+ if ( er instanceof Error ) {
136
111
throw er ; // Unhandled 'error' event
137
- } else {
138
- // At least give some kind of context to the user
139
- const errors = lazyErrors ( ) ;
140
- const err = new errors . Error ( 'ERR_UNHANDLED_ERROR' , er ) ;
141
- err . context = er ;
142
- throw err ;
143
112
}
144
- return false ;
113
+ // At least give some kind of context to the user
114
+ const errors = lazyErrors ( ) ;
115
+ const err = new errors . Error ( 'ERR_UNHANDLED_ERROR' , er ) ;
116
+ err . context = er ;
117
+ throw err ;
145
118
}
146
119
147
120
const handler = events [ type ] ;
148
121
149
122
if ( handler === undefined )
150
123
return false ;
151
124
152
- let needDomainExit = false ;
153
- if ( domain !== null && domain !== undefined && this !== process ) {
154
- domain . enter ( ) ;
155
- needDomainExit = true ;
156
- }
157
-
158
125
if ( typeof handler === 'function' ) {
159
126
handler . apply ( this , args ) ;
160
127
} else {
@@ -164,9 +131,6 @@ EventEmitter.prototype.emit = function emit(type, ...args) {
164
131
listeners [ i ] . apply ( this , args ) ;
165
132
}
166
133
167
- if ( needDomainExit )
168
- domain . exit ( ) ;
169
-
170
134
return true ;
171
135
} ;
172
136
0 commit comments