Skip to content
Permalink
Browse files

assert: improve performance to instantiate errors

This improves the performance for AssertionError by deactivating
duplicated stack frame creation.

PR-URL: #26738
Reviewed-By: Gus Caplan <me@gus.host>
Reviewed-By: Matteo Collina <matteo.collina@gmail.com>
Reviewed-By: Michaël Zasso <targos@protonmail.com>
Reviewed-By: Joyee Cheung <joyeec9h3@gmail.com>
  • Loading branch information...
BridgeAR committed Mar 20, 2019
1 parent f0f26ce commit afce91219359654b44df29e6ec1b730e2a73a919
Showing with 5 additions and 0 deletions.
  1. +5 −0 lib/internal/assert/assertion_error.js
@@ -300,6 +300,9 @@ class AssertionError extends Error {
stackStartFn
} = options;

const limit = Error.stackTraceLimit;
Error.stackTraceLimit = 0;

if (message != null) {
super(String(message));
} else {
@@ -387,6 +390,8 @@ class AssertionError extends Error {
}
}

Error.stackTraceLimit = limit;

this.generatedMessage = !message;
Object.defineProperty(this, 'name', {
value: 'AssertionError [ERR_ASSERTION]',

0 comments on commit afce912

Please sign in to comment.
You can’t perform that action at this time.