File tree 2 files changed +22
-5
lines changed
2 files changed +22
-5
lines changed Original file line number Diff line number Diff line change 515
515
var hasBeenNotified = hasBeenNotifiedProperty . get ( promise ) ;
516
516
if ( hasBeenNotified !== undefined ) {
517
517
hasBeenNotifiedProperty . delete ( promise ) ;
518
- if ( hasBeenNotified === true )
519
- process . emit ( 'rejectionHandled' , promise ) ;
518
+ if ( hasBeenNotified === true ) {
519
+ process . nextTick ( function ( ) {
520
+ process . emit ( 'rejectionHandled' , promise ) ;
521
+ } ) ;
522
+ }
523
+
520
524
}
521
525
}
522
526
523
527
process . _setupPromises ( function ( event , promise , reason ) {
524
528
if ( event === promiseRejectEvent . unhandled )
525
529
unhandledRejection ( promise , reason ) ;
526
530
else if ( event === promiseRejectEvent . handled )
527
- process . nextTick ( function ( ) {
528
- rejectionHandled ( promise ) ;
529
- } ) ;
531
+ rejectionHandled ( promise ) ;
530
532
else
531
533
NativeModule . require ( 'assert' ) . fail ( 'unexpected PromiseRejectEvent' ) ;
532
534
} ) ;
Original file line number Diff line number Diff line change @@ -275,6 +275,21 @@ asyncTest('Attaching a promise catch in a process.nextTick is soon enough to' +
275
275
} ) ;
276
276
} ) ;
277
277
278
+ asyncTest ( 'While inside setImmediate, catching a rejected promise derived ' +
279
+ 'from returning a rejected promise in a fulfillment handler ' +
280
+ 'prevents unhandledRejection' , function ( done ) {
281
+ onUnhandledFail ( done ) ;
282
+
283
+ setImmediate ( function ( ) {
284
+ // reproduces on first tick and inside of setImmediate
285
+ Promise
286
+ . resolve ( 'resolve' )
287
+ . then ( function ( ) {
288
+ return Promise . reject ( 'reject' ) ;
289
+ } ) . catch ( function ( e ) { } ) ;
290
+ } ) ;
291
+ } ) ;
292
+
278
293
// State adapation tests
279
294
asyncTest ( 'catching a promise which is asynchronously rejected (via' +
280
295
'resolution to an asynchronously-rejected promise) prevents' +
You can’t perform that action at this time.
0 commit comments