@@ -1747,7 +1747,7 @@ const Zone: ZoneType = (function(global: any) {
17471747 'long-stack-trace'
17481748 ] ;
17491749
1750- function attachZoneAndRemoveInternalZoneFrames ( error : any ) {
1750+ function attachZoneAndRemoveInternalZoneFrames ( error : any , zoneAwareError : any ) {
17511751 // Save original stack trace
17521752 error . originalStack = error . stack ;
17531753 // Process the stack trace and rewrite the frames.
@@ -1789,7 +1789,14 @@ const Zone: ZoneType = (function(global: any) {
17891789 }
17901790 }
17911791 }
1792- error . stack = error . zoneAwareStack = frames . join ( '\n' ) ;
1792+ const finalStack : string = frames . join ( '\n' ) ;
1793+ try {
1794+ error . stack = error . zoneAwareStack = finalStack ;
1795+ } catch ( nonWritableErr ) {
1796+ // in some browser, the error.stack is readonly such as PhantomJS
1797+ // so we need to store the stack frames to zoneAwareError directly
1798+ zoneAwareError . stack = finalStack ;
1799+ }
17931800 }
17941801 }
17951802
@@ -1820,7 +1827,7 @@ const Zone: ZoneType = (function(global: any) {
18201827 this [ __symbol__ ( 'error' ) ] = error ;
18211828 // 1. attach zone information to stack frame
18221829 // 2. remove zone internal stack frames
1823- attachZoneAndRemoveInternalZoneFrames ( error ) ;
1830+ attachZoneAndRemoveInternalZoneFrames ( error , this ) ;
18241831
18251832 // use defineProperties here instead of copy property value
18261833 // because of issue #595 which will break angular2.
0 commit comments