@@ -78,6 +78,16 @@ function renderLongStackTrace(frames: LongStackTrace[], stack?: string): string
7878 return longTrace . join ( NEWLINE ) ;
7979}
8080
81+ // if Error.stackTraceLimit is 0, means stack trace
82+ // is disabled, so we don't need to generate long stack trace
83+ // this will improve performance in some test(some test will
84+ // set stackTraceLimit to 0, https://github.com/angular/zone.js/issues/698
85+ function stackTracesEnabled ( ) : boolean {
86+ // Cast through any since this property only exists on Error in the nodejs
87+ // typings.
88+ return ( Error as any ) . stackTraceLimit > 0 ;
89+ }
90+
8191type LongStackTraceZoneSpec = ZoneSpec & { longStackTraceLimit : number } ;
8292
8393( Zone as any ) [ 'longStackTraceZoneSpec' ] = < LongStackTraceZoneSpec > {
@@ -99,11 +109,7 @@ type LongStackTraceZoneSpec = ZoneSpec & {longStackTraceLimit: number};
99109
100110 onScheduleTask : function (
101111 parentZoneDelegate : ZoneDelegate , currentZone : Zone , targetZone : Zone , task : Task ) : any {
102- if ( Error . stackTraceLimit > 0 ) {
103- // if Error.stackTraceLimit is 0, means stack trace
104- // is disabled, so we don't need to generate long stack trace
105- // this will improve performance in some test(some test will
106- // set stackTraceLimit to 0, https://github.com/angular/zone.js/issues/698
112+ if ( stackTracesEnabled ( ) ) {
107113 const currentTask = Zone . currentTask ;
108114 let trace = currentTask && currentTask . data && ( currentTask . data as any ) [ creationTrace ] || [ ] ;
109115 trace = [ new LongStackTrace ( ) ] . concat ( trace ) ;
@@ -127,11 +133,7 @@ type LongStackTraceZoneSpec = ZoneSpec & {longStackTraceLimit: number};
127133
128134 onHandleError : function (
129135 parentZoneDelegate : ZoneDelegate , currentZone : Zone , targetZone : Zone , error : any ) : boolean {
130- if ( Error . stackTraceLimit > 0 ) {
131- // if Error.stackTraceLimit is 0, means stack trace
132- // is disabled, so we don't need to generate long stack trace
133- // this will improve performance in some test(some test will
134- // set stackTraceLimit to 0, https://github.com/angular/zone.js/issues/698
136+ if ( stackTracesEnabled ( ) ) {
135137 const parentTask = Zone . currentTask || error . task ;
136138 if ( error instanceof Error && parentTask ) {
137139 const longStack =
@@ -154,7 +156,7 @@ function captureStackTraces(stackTraces: string[][], count: number): void {
154156}
155157
156158function computeIgnoreFrames ( ) {
157- if ( Error . stackTraceLimit <= 0 ) {
159+ if ( ! stackTracesEnabled ( ) ) {
158160 return ;
159161 }
160162 const frames : string [ ] [ ] = [ ] ;
0 commit comments