@@ -459,9 +459,9 @@ class EventTarget {
459459 result = FunctionPrototypeCall ( callback , this , arg ) ;
460460 }
461461 if ( result !== undefined && result !== null )
462- addCatch ( this , result , createEvent ( ) ) ;
462+ addCatch ( result ) ;
463463 } catch ( err ) {
464- emitUnhandledRejectionOrErr ( this , err , createEvent ( ) ) ;
464+ emitUncaughtException ( err ) ;
465465 }
466466
467467 handler = next ;
@@ -624,19 +624,19 @@ function isEventTarget(obj) {
624624 return obj ?. constructor ?. [ kIsEventTarget ] ;
625625}
626626
627- function addCatch ( that , promise , event ) {
627+ function addCatch ( promise ) {
628628 const then = promise . then ;
629629 if ( typeof then === 'function' ) {
630630 FunctionPrototypeCall ( then , promise , undefined , function ( err ) {
631631 // The callback is called with nextTick to avoid a follow-up
632632 // rejection from this promise.
633- process . nextTick ( emitUnhandledRejectionOrErr , that , err , event ) ;
633+ emitUncaughtException ( err ) ;
634634 } ) ;
635635 }
636636}
637637
638- function emitUnhandledRejectionOrErr ( that , err , event ) {
639- process . emit ( 'error' , err , event ) ;
638+ function emitUncaughtException ( err ) {
639+ process . nextTick ( ( ) => { throw err ; } ) ;
640640}
641641
642642function makeEventHandler ( handler ) {
0 commit comments