@@ -53,13 +53,13 @@ describe('Stack parsing', () => {
53
53
} ) ;
54
54
55
55
test ( 'parses object in fn name' , ( ) => {
56
- const err : { [ key : string ] : any } = { } ;
56
+ const err = new Error ( ) ;
57
57
err . stack =
58
58
'Error: Foo\n' +
59
59
' at [object Object].global.every [as _onTimeout] (/Users/hoitz/develop/test.coffee:36:3)\n' +
60
60
' at Timer.listOnTimeout [as ontimeout] (timers.js:110:15)\n' ;
61
61
62
- const frames = parseStackFrames ( err as Error ) ;
62
+ const frames = parseStackFrames ( err ) ;
63
63
64
64
expect ( frames ) . toEqual ( [
65
65
{
@@ -89,15 +89,15 @@ describe('Stack parsing', () => {
89
89
} ) ;
90
90
91
91
test ( 'parses corrupt stack' , ( ) => {
92
- const err : { [ key : string ] : any } = { } ;
92
+ const err = new Error ( ) ;
93
93
err . stack =
94
94
'AssertionError: true == false\n' +
95
95
' fuck' +
96
96
' at Test.run (/Users/felix/code/node-fast-or-slow/lib/test.js:45:10)\n' +
97
97
'oh no' +
98
98
' at TestCase.run (/Users/felix/code/node-fast-or-slow/lib/test_case.js:61:8)\n' ;
99
99
100
- const frames = parseStackFrames ( err as Error ) ;
100
+ const frames = parseStackFrames ( err ) ;
101
101
102
102
expect ( frames ) . toEqual ( [
103
103
{
@@ -120,13 +120,13 @@ describe('Stack parsing', () => {
120
120
} ) ;
121
121
122
122
test ( 'parses with missing column numbers' , ( ) => {
123
- const err : { [ key : string ] : any } = { } ;
123
+ const err = new Error ( ) ;
124
124
err . stack =
125
125
'AssertionError: true == false\n' +
126
126
' at Test.fn (/Users/felix/code/node-fast-or-slow/test/fast/example/test-example.js:6)\n' +
127
127
' at Test.run (/Users/felix/code/node-fast-or-slow/lib/test.js:45)' ;
128
128
129
- const frames = parseStackFrames ( err as Error ) ;
129
+ const frames = parseStackFrames ( err ) ;
130
130
131
131
expect ( frames ) . toEqual ( [
132
132
{
@@ -147,7 +147,7 @@ describe('Stack parsing', () => {
147
147
} ) ;
148
148
149
149
test ( 'parses with native methods' , ( ) => {
150
- const err : { [ key : string ] : any } = { } ;
150
+ const err = new Error ( ) ;
151
151
err . stack =
152
152
'AssertionError: true == false\n' +
153
153
' at Test.fn (/Users/felix/code/node-fast-or-slow/test/fast/example/test-example.js:6:10)\n' +
@@ -157,7 +157,7 @@ describe('Stack parsing', () => {
157
157
' at Array.0 (native)\n' +
158
158
' at EventEmitter._tickCallback (node.js:126:26)' ;
159
159
160
- const frames = parseStackFrames ( err as Error ) ;
160
+ const frames = parseStackFrames ( err ) ;
161
161
162
162
expect ( frames ) . toEqual ( [
163
163
{
@@ -209,16 +209,16 @@ describe('Stack parsing', () => {
209
209
} ) ;
210
210
211
211
test ( 'parses with file only' , ( ) => {
212
- const err : { [ key : string ] : any } = { } ;
212
+ const err = new Error ( ) ;
213
213
err . stack = 'AssertionError: true == false\n' + ' at /Users/felix/code/node-fast-or-slow/lib/test_case.js:80:10' ;
214
214
215
- const frames = parseStackFrames ( err as Error ) ;
215
+ const frames = parseStackFrames ( err ) ;
216
216
217
217
expect ( frames ) . toEqual ( [
218
218
{
219
219
filename : '/Users/felix/code/node-fast-or-slow/lib/test_case.js' ,
220
220
module : 'test_case' ,
221
- function : 'undefined. <anonymous>' ,
221
+ function : '<anonymous>' ,
222
222
lineno : 80 ,
223
223
colno : 10 ,
224
224
in_app : true ,
@@ -227,18 +227,18 @@ describe('Stack parsing', () => {
227
227
} ) ;
228
228
229
229
test ( 'parses with multi line message' , ( ) => {
230
- const err : { [ key : string ] : any } = { } ;
230
+ const err = new Error ( ) ;
231
231
err . stack =
232
232
'AssertionError: true == false\nAnd some more shit\n' +
233
233
' at /Users/felix/code/node-fast-or-slow/lib/test_case.js:80:10' ;
234
234
235
- const frames = parseStackFrames ( err as Error ) ;
235
+ const frames = parseStackFrames ( err ) ;
236
236
237
237
expect ( frames ) . toEqual ( [
238
238
{
239
239
filename : '/Users/felix/code/node-fast-or-slow/lib/test_case.js' ,
240
240
module : 'test_case' ,
241
- function : 'undefined. <anonymous>' ,
241
+ function : '<anonymous>' ,
242
242
lineno : 80 ,
243
243
colno : 10 ,
244
244
in_app : true ,
@@ -247,12 +247,12 @@ describe('Stack parsing', () => {
247
247
} ) ;
248
248
249
249
test ( 'parses with anonymous fn call' , ( ) => {
250
- const err : { [ key : string ] : any } = { } ;
250
+ const err = new Error ( ) ;
251
251
err . stack =
252
252
'AssertionError: expected [] to be arguments\n' +
253
253
' at Assertion.prop.(anonymous function) (/Users/den/Projects/should.js/lib/should.js:60:14)\n' ;
254
254
255
- const frames = parseStackFrames ( err as Error ) ;
255
+ const frames = parseStackFrames ( err ) ;
256
256
257
257
expect ( frames ) . toEqual ( [
258
258
{
@@ -267,13 +267,13 @@ describe('Stack parsing', () => {
267
267
} ) ;
268
268
269
269
test ( 'parses with braces in paths' , ( ) => {
270
- const err : { [ key : string ] : any } = { } ;
270
+ const err = new Error ( ) ;
271
271
err . stack =
272
272
'AssertionError: true == false\n' +
273
273
' at Test.run (/Users/felix (something)/code/node-fast-or-slow/lib/test.js:45:10)\n' +
274
274
' at TestCase.run (/Users/felix (something)/code/node-fast-or-slow/lib/test_case.js:61:8)\n' ;
275
275
276
- const frames = parseStackFrames ( err as Error ) ;
276
+ const frames = parseStackFrames ( err ) ;
277
277
278
278
expect ( frames ) . toEqual ( [
279
279
{
@@ -294,4 +294,88 @@ describe('Stack parsing', () => {
294
294
} ,
295
295
] ) ;
296
296
} ) ;
297
+
298
+ test ( 'parses with async frames' , ( ) => {
299
+ // https://github.com/getsentry/sentry-javascript/issues/4692#issuecomment-1063835795
300
+ const err = new Error ( ) ;
301
+ err . stack =
302
+ 'Error: Client request error\n' +
303
+ ' at Object.httpRequestError (file:///code/node_modules/@waroncancer/gaia/lib/error/error-factory.js:17:73)\n' +
304
+ ' at Object.run (file:///code/node_modules/@waroncancer/gaia/lib/http-client/http-client.js:81:36)\n' +
305
+ ' at processTicksAndRejections (node:internal/process/task_queues:96:5)\n' +
306
+ ' at async Object.send (file:///code/lib/post-created/send-post-created-notification-module.js:17:27)\n' +
307
+ ' at async each (file:///code/lib/process-post-events-module.js:14:21)\n' +
308
+ ' at async Runner.processEachMessage (/code/node_modules/kafkajs/src/consumer/runner.js:151:9)\n' +
309
+ ' at async onBatch (/code/node_modules/kafkajs/src/consumer/runner.js:326:9)\n' +
310
+ ' at async /code/node_modules/kafkajs/src/consumer/runner.js:376:15\n' ;
311
+
312
+ const frames = parseStackFrames ( err ) ;
313
+
314
+ expect ( frames ) . toEqual ( [
315
+ {
316
+ filename : '/code/node_modules/kafkajs/src/consumer/runner.js' ,
317
+ module : 'kafkajs.src.consumer:runner' ,
318
+ function : '<anonymous>' ,
319
+ lineno : 376 ,
320
+ colno : 15 ,
321
+ in_app : false ,
322
+ } ,
323
+ {
324
+ filename : '/code/node_modules/kafkajs/src/consumer/runner.js' ,
325
+ module : 'kafkajs.src.consumer:runner' ,
326
+ function : 'onBatch' ,
327
+ lineno : 326 ,
328
+ colno : 9 ,
329
+ in_app : false ,
330
+ } ,
331
+ {
332
+ filename : '/code/node_modules/kafkajs/src/consumer/runner.js' ,
333
+ module : 'kafkajs.src.consumer:runner' ,
334
+ function : 'Runner.processEachMessage' ,
335
+ lineno : 151 ,
336
+ colno : 9 ,
337
+ in_app : false ,
338
+ } ,
339
+ {
340
+ filename : '/code/lib/process-post-events-module.js' ,
341
+ module : 'process-post-events-module' ,
342
+ function : 'each' ,
343
+ lineno : 14 ,
344
+ colno : 21 ,
345
+ in_app : true ,
346
+ } ,
347
+ {
348
+ filename : '/code/lib/post-created/send-post-created-notification-module.js' ,
349
+ module : 'send-post-created-notification-module' ,
350
+ function : 'Object.send' ,
351
+ lineno : 17 ,
352
+ colno : 27 ,
353
+ in_app : true ,
354
+ } ,
355
+ {
356
+ filename : 'node:internal/process/task_queues' ,
357
+ module : 'task_queues' ,
358
+ function : 'processTicksAndRejections' ,
359
+ lineno : 96 ,
360
+ colno : 5 ,
361
+ in_app : false ,
362
+ } ,
363
+ {
364
+ filename : '/code/node_modules/@waroncancer/gaia/lib/http-client/http-client.js' ,
365
+ module : '@waroncancer.gaia.lib.http-client:http-client' ,
366
+ function : 'Object.run' ,
367
+ lineno : 81 ,
368
+ colno : 36 ,
369
+ in_app : false ,
370
+ } ,
371
+ {
372
+ filename : '/code/node_modules/@waroncancer/gaia/lib/error/error-factory.js' ,
373
+ module : '@waroncancer.gaia.lib.error:error-factory' ,
374
+ function : 'Object.httpRequestError' ,
375
+ lineno : 17 ,
376
+ colno : 73 ,
377
+ in_app : false ,
378
+ } ,
379
+ ] ) ;
380
+ } ) ;
297
381
} ) ;
0 commit comments