@@ -868,7 +868,7 @@ const Zone: ZoneType = (function(global: any) {
868868 let _currentTask : Task = null ;
869869 let _microTaskQueue : Task [ ] = [ ] ;
870870 let _isDrainingMicrotaskQueue : boolean = false ;
871- let _uncaughtPromiseErrors : UncaughtPromiseError [ ] = [ ] ;
871+ const _uncaughtPromiseErrors : UncaughtPromiseError [ ] = [ ] ;
872872 let _drainScheduled : boolean = false ;
873873
874874 function scheduleQueueDrain ( ) {
@@ -894,7 +894,8 @@ const Zone: ZoneType = (function(global: any) {
894894 'Unhandled Promise rejection:' , rejection instanceof Error ? rejection . message : rejection ,
895895 '; Zone:' , ( < Zone > e . zone ) . name ,
896896 '; Task:' , e . task && ( < Task > e . task ) . source ,
897- '; Value:' , rejection
897+ '; Value:' , rejection ,
898+ rejection instanceof Error ? rejection . stack : undefined
898899 ) ;
899900 }
900901 console . error ( e ) ;
@@ -916,10 +917,8 @@ const Zone: ZoneType = (function(global: any) {
916917 }
917918 }
918919 while ( _uncaughtPromiseErrors . length ) {
919- const uncaughtPromiseErrors = _uncaughtPromiseErrors ;
920- _uncaughtPromiseErrors = [ ] ;
921- for ( let i = 0 ; i < uncaughtPromiseErrors . length ; i ++ ) {
922- const uncaughtPromiseError : UncaughtPromiseError = uncaughtPromiseErrors [ i ] ;
920+ while ( _uncaughtPromiseErrors . length ) {
921+ const uncaughtPromiseError : UncaughtPromiseError = _uncaughtPromiseErrors . shift ( ) ;
923922 try {
924923 uncaughtPromiseError . zone . runGuarded ( ( ) => { throw uncaughtPromiseError ; } ) ;
925924 } catch ( e ) {
@@ -1119,5 +1118,7 @@ const Zone: ZoneType = (function(global: any) {
11191118 }
11201119 }
11211120
1121+ // This is not part of public API, but it is usefull for tests, so we expose it.
1122+ Promise [ Zone . __symbol__ ( 'uncaughtPromiseErrors' ) ] = _uncaughtPromiseErrors ;
11221123 return global . Zone = Zone ;
11231124} ) ( typeof window === 'undefined' ? global : window ) ;
0 commit comments