This repository was archived by the owner on Feb 26, 2024. It is now read-only.
File tree 2 files changed +29
-21
lines changed
2 files changed +29
-21
lines changed Original file line number Diff line number Diff line change @@ -15,7 +15,7 @@ const IGNORE_FRAMES: {[k: string]: true} = {};
15
15
const creationTrace = '__creationTrace__' ;
16
16
const ERROR_TAG = 'STACKTRACE TRACKING' ;
17
17
const SEP_TAG = '__SEP_TAG__' ;
18
- let sepTemplate = ' ';
18
+ let sepTemplate : string = SEP_TAG + '@[native] ';
19
19
20
20
class LongStackTrace {
21
21
error : Error = getStacktrace ( ) ;
@@ -137,19 +137,23 @@ function computeIgnoreFrames() {
137
137
const frames2 = frames [ 1 ] ;
138
138
for ( let i = 0 ; i < frames1 . length ; i ++ ) {
139
139
const frame1 = frames1 [ i ] ;
140
- const frame2 = frames2 [ i ] ;
141
- if ( ! sepTemplate && frame1 . indexOf ( ERROR_TAG ) == - 1 ) {
142
- sepTemplate = frame1 . replace ( / ^ ( \s * ( a t ) ? \s * ) ( [ \w \/ \< ] + ) / , '$1' + SEP_TAG ) ;
140
+ if ( frame1 . indexOf ( ERROR_TAG ) == - 1 ) {
141
+ let match = frame1 . match ( / ^ \s * a t \s + / ) ;
142
+ if ( match ) {
143
+ sepTemplate = match [ 0 ] + SEP_TAG + ' (http://localhost)' ;
144
+ break ;
145
+ }
143
146
}
147
+ }
148
+
149
+ for ( let i = 0 ; i < frames1 . length ; i ++ ) {
150
+ const frame1 = frames1 [ i ] ;
151
+ const frame2 = frames2 [ i ] ;
144
152
if ( frame1 === frame2 ) {
145
153
IGNORE_FRAMES [ frame1 ] = true ;
146
154
} else {
147
155
break ;
148
156
}
149
157
}
150
- if ( ! sepTemplate ) {
151
- // If we could not find it default to this text.
152
- sepTemplate = SEP_TAG + '@[native code]' ;
153
- }
154
158
}
155
159
computeIgnoreFrames ( ) ;
Original file line number Diff line number Diff line change @@ -28,17 +28,25 @@ describe('longStackTraceZone', function() {
28
28
log = [ ] ;
29
29
} ) ;
30
30
31
+ function expectElapsed ( stack : string , expectedCount : number ) {
32
+ try {
33
+ let actualCount = stack . split ( '_Elapsed_' ) . length ;
34
+ if ( actualCount !== expectedCount ) {
35
+ expect ( actualCount ) . toEqual ( expectedCount ) ;
36
+ console . log ( stack ) ;
37
+ }
38
+ } catch ( e ) {
39
+ expect ( e ) . toBe ( null ) ;
40
+ }
41
+ }
42
+
31
43
it ( 'should produce long stack traces' , function ( done ) {
32
44
lstz . run ( function ( ) {
33
45
setTimeout ( function ( ) {
34
46
setTimeout ( function ( ) {
35
47
setTimeout ( function ( ) {
36
- try {
37
- expect ( log [ 0 ] . stack . split ( 'Elapsed' ) . length ) . toBe ( 3 ) ;
38
- done ( ) ;
39
- } catch ( e ) {
40
- expect ( e ) . toBe ( null ) ;
41
- }
48
+ expectElapsed ( log [ 0 ] . stack , 3 ) ;
49
+ done ( ) ;
42
50
} , 0 ) ;
43
51
throw new Error ( 'Hello' ) ;
44
52
} , 0 ) ;
@@ -81,12 +89,8 @@ describe('longStackTraceZone', function() {
81
89
fail ( 'should not get here' ) ;
82
90
} ) ;
83
91
setTimeout ( function ( ) {
84
- try {
85
- expect ( log [ 0 ] . stack . split ( 'Elapsed' ) . length ) . toBe ( 5 ) ;
86
- done ( ) ;
87
- } catch ( e ) {
88
- expect ( e ) . toBe ( null ) ;
89
- }
92
+ expectElapsed ( log [ 0 ] . stack , 5 ) ;
93
+ done ( ) ;
90
94
} , 0 ) ;
91
95
} , 0 ) ;
92
96
} , 0 ) ;
@@ -105,7 +109,7 @@ describe('longStackTraceZone', function() {
105
109
promise . catch ( function ( error ) {
106
110
// should be able to get long stack trace
107
111
const longStackFrames : string = longStackTraceZoneSpec . getLongStackTrace ( error ) ;
108
- expect ( longStackFrames . split ( 'Elapsed' ) . length ) . toBe ( 4 ) ;
112
+ expectElapsed ( longStackFrames , 4 ) ;
109
113
done ( ) ;
110
114
} ) ;
111
115
} , 0 ) ;
You can’t perform that action at this time.
0 commit comments