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

util: pass on additional error() args #4279

Closed
wants to merge 1 commit into from

Conversation

mscdex
Copy link
Contributor

@mscdex mscdex commented Dec 14, 2015

This fixes breakage introduced in 94b9948 when writing the max EventEmitter listeners warning to stderr.

@mscdex mscdex added the util Issues and PRs related to the built-in util module. label Dec 14, 2015
@@ -18,7 +18,11 @@ exports.printDeprecationMessage = function(msg, warned) {
};

exports.error = function(msg) {
console.error(`${prefix}${msg}`);
if (arguments.length > 1) {
arguments[0] = `${prefix}${msg}`;
Copy link
Member

Choose a reason for hiding this comment

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

It probably doesn't really matter here but V8 doesn't like it when you modify arguments.

Copy link
Contributor Author

Choose a reason for hiding this comment

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

I thought so too, but according to @petkaantonov's "Optimization killers" page it doesn't apply if the script/function is in strict mode?

Copy link
Member

Choose a reason for hiding this comment

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

I checked and Crankshaft bails out with 'Bad value context for arguments value' as the deopt reason; TurboFan seems to be able to optimize it, though.

If writing it like this is unavoidable, I'd at least DRY the formatting into const fmt = ${prefix}${msg};

Copy link
Contributor Author

Choose a reason for hiding this comment

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

Would cloning arguments and mutating that instead be better?

Copy link
Member

Choose a reason for hiding this comment

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

personally I'd be more comfortable with that.

Copy link
Contributor Author

Choose a reason for hiding this comment

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

Done.

const args = new Array(arguments.length);
args[0] = fmt;
for (let i = 1; i < arguments.length; ++i)
args[i] = arguments[i];
Copy link
Member

Choose a reason for hiding this comment

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

why not simply Array.prototype.slice.call(arguments) then args[0] = fmt after?

Copy link
Contributor Author

Choose a reason for hiding this comment

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

Because (AFAIK this is still the case) passing arguments to a function other than fn.apply() causes deopts in v8.

Copy link
Member

Choose a reason for hiding this comment

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

ah.. right, keep forgetting about that. carry on then :-)

Copy link
Contributor

Choose a reason for hiding this comment

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

Are we avoiding [...arguments] (or function (...rest) args) to make the LTS backporting process easier?

Copy link
Contributor Author

Choose a reason for hiding this comment

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

Well if for no other reason than I think spread is slow in v8 still? I am not 100% sure if that changed in v8 4.7 or not...

@jasnell
Copy link
Member

jasnell commented Dec 15, 2015

LGTM

This fixes breakage introduced in 94b9948 when writing the max
EventEmitter listeners warning to stderr.
@mscdex
Copy link
Contributor Author

mscdex commented Dec 15, 2015

CI is all green except unrelated, flaky tests: https://ci.nodejs.org/job/node-test-pull-request/1000/

@bnoordhuis
Copy link
Member

Gnarly but LGTM.

mscdex added a commit that referenced this pull request Dec 17, 2015
This fixes breakage introduced in 94b9948 when writing the max
EventEmitter listeners warning to stderr.

PR-URL: #4279
Reviewed-By: James M Snell <[email protected]>
Reviewed-By: Ben Noordhuis <[email protected]>
@mscdex
Copy link
Contributor Author

mscdex commented Dec 17, 2015

Landed in 0b43c08.

@mscdex mscdex closed this Dec 17, 2015
@mscdex mscdex deleted the fix-events-stderr-output branch December 17, 2015 18:07
@jasnell jasnell mentioned this pull request Dec 17, 2015
@MylesBorins
Copy link
Contributor

The referenced commit that is broken 94b9948 is a semver Major change not in the v4.x branch
I'm removing lts-watch for now @jasnell feel free to readd

@MylesBorins
Copy link
Contributor

As this commit has a dont-land-on-v5.x I'm assuming the same is true for v4.x adding the appropriate label

scovetta pushed a commit to scovetta/node that referenced this pull request Apr 2, 2016
This fixes breakage introduced in 94b9948 when writing the max
EventEmitter listeners warning to stderr.

PR-URL: nodejs#4279
Reviewed-By: James M Snell <[email protected]>
Reviewed-By: Ben Noordhuis <[email protected]>
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
util Issues and PRs related to the built-in util module.
Projects
None yet
Development

Successfully merging this pull request may close these issues.

6 participants