@@ -261,10 +261,16 @@ function uvException(ctx) {
261
261
message += ` -> '${ dest } '` ;
262
262
}
263
263
264
+ // Reducing the limit improves the performance significantly. We do not loose
265
+ // the stack frames due to the `captureStackTrace()` function that is called
266
+ // later.
267
+ const tmpLimit = Error . stackTraceLimit ;
268
+ Error . stackTraceLimit = 0 ;
264
269
// Pass the message to the constructor instead of setting it on the object
265
270
// to make sure it is the same as the one created in C++
266
271
// eslint-disable-next-line no-restricted-syntax
267
272
const err = new Error ( message ) ;
273
+ Error . stackTraceLimit = tmpLimit ;
268
274
269
275
for ( const prop of Object . keys ( ctx ) ) {
270
276
if ( prop === 'message' || prop === 'path' || prop === 'dest' ) {
@@ -307,8 +313,14 @@ function uvExceptionWithHostPort(err, syscall, address, port) {
307
313
details = ` ${ address } ` ;
308
314
}
309
315
316
+ // Reducing the limit improves the performance significantly. We do not loose
317
+ // the stack frames due to the `captureStackTrace()` function that is called
318
+ // later.
319
+ const tmpLimit = Error . stackTraceLimit ;
320
+ Error . stackTraceLimit = 0 ;
310
321
// eslint-disable-next-line no-restricted-syntax
311
322
const ex = new Error ( `${ message } ${ details } ` ) ;
323
+ Error . stackTraceLimit = tmpLimit ;
312
324
ex . code = code ;
313
325
ex . errno = code ;
314
326
ex . syscall = syscall ;
@@ -377,9 +389,15 @@ function exceptionWithHostPort(err, syscall, address, port, additional) {
377
389
details += ` - Local (${ additional } )` ;
378
390
}
379
391
392
+ // Reducing the limit improves the performance significantly. We do not loose
393
+ // the stack frames due to the `captureStackTrace()` function that is called
394
+ // later.
395
+ const tmpLimit = Error . stackTraceLimit ;
396
+ Error . stackTraceLimit = 0 ;
380
397
// eslint-disable-next-line no-restricted-syntax
381
398
const ex = new Error ( `${ syscall } ${ code } ${ details } ` ) ;
382
399
// TODO(joyeecheung): errno is supposed to err, like in uvException
400
+ Error . stackTraceLimit = tmpLimit ;
383
401
ex . code = ex . errno = code ;
384
402
ex . syscall = syscall ;
385
403
ex . address = address ;
@@ -410,9 +428,15 @@ function dnsException(code, syscall, hostname) {
410
428
}
411
429
}
412
430
const message = `${ syscall } ${ code } ${ hostname ? ` ${ hostname } ` : '' } ` ;
431
+ // Reducing the limit improves the performance significantly. We do not loose
432
+ // the stack frames due to the `captureStackTrace()` function that is called
433
+ // later.
434
+ const tmpLimit = Error . stackTraceLimit ;
435
+ Error . stackTraceLimit = 0 ;
413
436
// eslint-disable-next-line no-restricted-syntax
414
437
const ex = new Error ( message ) ;
415
438
// TODO(joyeecheung): errno is supposed to be a number / err, like in
439
+ Error . stackTraceLimit = tmpLimit ;
416
440
// uvException.
417
441
ex . errno = code ;
418
442
ex . code = code ;
0 commit comments