assert: improve performance to instantiate errors · nodejs/node@afce912 (original) (raw)

Original file line number Diff line number Diff line change
@@ -300,6 +300,9 @@ class AssertionError extends Error {
300 300 stackStartFn
301 301 } = options;
302 302
303 +const limit = Error.stackTraceLimit;
304 +Error.stackTraceLimit = 0;
305 +
303 306 if (message != null) {
304 307 super(String(message));
305 308 } else {
@@ -387,6 +390,8 @@ class AssertionError extends Error {
387 390 }
388 391 }
389 392
393 +Error.stackTraceLimit = limit;
394 +
390 395 this.generatedMessage = !message;
391 396 Object.defineProperty(this, 'name', {
392 397 value: 'AssertionError [ERR_ASSERTION]',