Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

console,internal/errors: improve error perf #13743

Closed
wants to merge 2 commits into from
Closed
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
9 changes: 4 additions & 5 deletions lib/console.js
Original file line number Diff line number Diff line change
Expand Up @@ -151,11 +151,10 @@ Console.prototype.timeEnd = function timeEnd(label) {


Console.prototype.trace = function trace(...args) {
// TODO probably can to do this better with V8's debug object once that is
// exposed.
var err = new Error();
err.name = 'Trace';
err.message = util.format.apply(null, args);
const err = {
name: 'Trace',
message: util.format.apply(null, args)
};
Error.captureStackTrace(err, trace);
this.error(err.stack);
};
Expand Down
1 change: 0 additions & 1 deletion lib/internal/errors.js
Original file line number Diff line number Diff line change
Expand Up @@ -28,7 +28,6 @@ function makeNodeError(Base) {
constructor(key, ...args) {
super(message(key, args));
this[kCode] = key;
Error.captureStackTrace(this, NodeError);
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I'm -1 on removing this line. The fact that NodeError is being used in here should not be visible to the end user. This intentionally removes that frame from the stack trace to provide that transparency.

Copy link
Member Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

The frame is not visible because newer v8 versions remove the constructor frame by default.
That's the reason why I removed the Error.captureStackTrace call. Do you maybe know a better description for the commit message to make it clearer?

Copy link
Member Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I checked all other occurrences as well and they are always needed besides here.

Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

oh nice... I knew that change was coming but I wasn't expecting it until 6.x for some reason. :-) ... that's a happy surprise. I withdraw the objection then!

}

get name() {
Expand Down