-
Notifications
You must be signed in to change notification settings - Fork 29.8k
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
take ownership of prepareStackTrace for upstream v8 changes #23926
Conversation
I'm also unsure of how this should be semver classified. |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
1st commit looks good with nits, and style conformance.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
4th commit looks good with nits.
+1 I like the idea of owning |
fe70f4e
to
f36a5e3
Compare
@nodejs/assert can someone take a look at how this effects |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
LGTM
I've compiled the PR but haven't had a chance to check it against my use case. I should be able to in the next couple days though. Update: It looks like I can work with this change. It doesn't re-decorate decorated stacks so for me this should be OK. |
@nodejs/assert another ping... can someone take a look at what changes need to be made to assertion error decoration |
Curiosity CI: https://ci.nodejs.org/job/node-test-pull-request/18320/ |
@BridgeAR Any chance you have some time to look at this proposed change? |
lib/internal/bootstrap/node.js
Outdated
return `${sourceLine} | ||
${' '.repeat(startPosition)}${'^'.repeat(endPosition - startPosition)} | ||
${errorString} | ||
at ${trace.join('\n at ')}`; |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Nit: We do not really use multi line template strings in /lib. It would be nice to replace this using string concat.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
why
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
why
That one of my favorite questions ;)
Sometimes the answer is "tradition", but in this case I think it's readability, as it breaks the indentation.
There also might be some weirdness in Windows where EOL is \r\n
if you set git to autocrlf=true
, and that changes the strings. I'm so so sorry and a little ashamed for my prefered platform, but then again macOS has .DS_Store
files so...
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
take your vote i guess
return `${resourceName}:${lineNumber}
${sourceLine}
${' '.repeat(startPosition)}${'^'.repeat(endPosition - startPosition)}
${errorString}
at ${trace.join('\n at ')}`;
vs
return `${resourceName}:${lineNumber}\n${sourceLine}\n` +
' '.repeat(startPosition) + '^'.repeat(endPosition - startPosition) +
`\n\n${errorString}\n at ${trace.join('\n at ')}`;
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
It's probably going to look a bit better if you break at the end of every \n
..
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
@joyeecheung like this?
return `${resourceName}:${lineNumber}\n${sourceLine}\n` +
' '.repeat(startPosition) + '^'.repeat(endPosition - startPosition) +
'\n' +
'\n' +
errorString +
'\n' +
` at ${trace.join('\n at ')}`;
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Maybe (just to reduce the '\n' kruft):
const numberOfCarrots = endPosition - startPosition;
const traceLines = [
`${resourceName}:${lineNumber}`,
`${sourceLine}`,
' '.repeat(startPosition) + '^'.repeat(numberOfCarrots),
'',
errorString,
...(trace.map((t) => ` at ${t}`)),
];
return traceLines.join('\n');
(carrot is funnier than carat)
Also could concat the trace more elegantly:
errorString,
];
traceLines = traceLines.concat(trace.map((t) => ` at ${t}`))
return traceLines.join('\n');
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
all of these are equally unreadable and the last one is creating an array just for the purpose of joining it...
i understand the indentation hazard but that's why we have tests right?
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
all of these are equally unreadable and the last one is creating an array just for the purpose of joining it...
No strong argument from me... Trying to make the best of a complicated situation.
as for the array, it's probably going to be the last code run by the process, so..
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
@devsnek it has been something that we tried to stick to in the whole code base. Not everyone is aware how multi line template strings actually work as people forget that leading spaces actually count. This was an issue in multiple PRs so far. So it's not only about the readability but about correctness as well (not in this specific PR but as a general issue).
Sadly there's no eslint rule to only forbid multi line template strings. We should probably write one to enforce this.
I have to compile this on my own and play around with it. If I understand this correct it will from now on always attach the source to the stack (if the user did not override the function). That is great! It would be nice if the error decoration could be expanded to cover multiple line statements fully and not only print the first line of the statement. Besides that it seems like the position indicator is not always correct (I checked some error output), so that should be looked at again. It does not directly seem to impact We definitely have to think about changing the simple assert error message again before this lands since it would otherwise print redundant information. @devsnek please correct me if I am wrong with anything I said here. |
@BridgeAR i think removing it entirely would make sense with this change.
|
603c5da
to
069e826
Compare
d2764d5
to
a55c34f
Compare
9325c95
to
2f00fbf
Compare
@joyeecheung does the current init code here make sense? |
9272abf
to
a647319
Compare
ee4d8bd
to
73be33e
Compare
Refs https://crbug.com/v8/7848 PR-URL: nodejs#23926 Reviewed-By: Refael Ackermann <[email protected]> Reviewed-By: Joyee Cheung <[email protected]>
Landed in b046bd1 |
Refs https://crbug.com/v8/7848 PR-URL: #23926 Reviewed-By: Refael Ackermann <[email protected]> Reviewed-By: Joyee Cheung <[email protected]>
These changes exist for a few reasons:
process.binding('util')
to stop node from decorating errors if they want to do their own thing.Closes #21958
/cc @BridgeAR @joyeecheung @bmeck @jdalton @mmarchini @ljharb
Checklist
make -j4 test
(UNIX), orvcbuild test
(Windows) passes