-
Notifications
You must be signed in to change notification settings - Fork 30.1k
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
module: always decorate thrown errors #4287
Conversation
CI is all green except flaky tests and CI issues: https://ci.nodejs.org/job/node-test-pull-request/1001/ |
LGTM |
Using the normal workflow, this will cause two arrow messages to be printed. For example:
Where |
From a quick test, it looks like removing the arrow information from |
Hrmm... what about adding/checking a "decorated" flag as another hidden value on the error object? |
57a9169
to
490c4b8
Compare
@cjihrig Alright, I added a 'decorated' flag and a new test for uncaught errors. CI is all green except flaky tests/CI issues: https://ci.nodejs.org/job/node-test-pull-request/1006/ |
490c4b8
to
fbcb95a
Compare
`require('${badSyntaxPath}')` | ||
]; | ||
const result = spawnSync(process.argv[0], args, { encoding: 'utf8' }); | ||
matches = err.stack.match(/var foo bar;/g); |
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.
Should this use result
?
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.
Fixed.
9dc88d1
to
ed203d0
Compare
Incorporated suggestions and CI is green except flaky tests: https://ci.nodejs.org/job/node-test-pull-request/1010/ |
LGTM |
err.stack = arrow + err.stack; | ||
exports.setHiddenValue(err, 'decorated', true); |
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.
I'd probably give this a slightly more unique name, e.g. 'node:decorated'
. (Ditto for 'arrowMessage'
although this PR didn't introduce that.)
semver-minor? |
ed203d0
to
ac1633b
Compare
@bnoordhuis I've made your suggested changes. LGTY now? |
Local<Value> decorated = err_obj->GetHiddenValue(env->decorated_string()); | ||
return (!decorated.IsEmpty() && | ||
decorated->IsBoolean() && | ||
decorated->BooleanValue()); |
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.
Superfluous parentheses and you can shorten it to return !decorated.IsEmpty() && decorated->IsTrue()
, which should also be infinitesimally faster.
LGTM with a nit and a suggestion. |
This provides more information when encountering a syntax or similar error when executing a file with require().
ac1633b
to
e7ac2fc
Compare
Updated commit. Last CI run: https://ci.nodejs.org/job/node-test-pull-request/1022/ |
@jasnell I'm not sure how this fits in (if at all) with whatever was agreed upon on with regard to changing errors and semver-ness, but my guess would be semver-major since it's changing the formatting of the stack trace? |
Landed in 18490d3. |
This provides more information when encountering a syntax or similar error when executing a file with require(). Fixes: nodejs#4286 PR-URL: nodejs#4287 Reviewed-By: Ben Noordhuis <info@bnoordhuis.nl> Reviewed-By: Colin Ihrig <cjihrig@gmail.com>
Notable changes: * general: Several minor performance improvements: - lib: Use arrow functions instead of bind where possible (Minwoo Jung) nodejs#3622 - node: Improved accessor perf of process.env (Trevor Norris) nodejs#3780 - **node**: Improved performance of hrtime() (Trevor Norris) nodejs#3780 - node: Improved GetActiveHandles performance (Trevor Norris) nodejs#3780 * module: Errors during require() now provide more information (Brian White) nodejs#4287
Marking as semver-major due to the error handling change. It's not clear if this is major or minor tho. @nodejs/ctc |
This provides more information when encountering a syntax or similar error when executing a file with require(). Fixes: nodejs#4286 PR-URL: nodejs#4287 Reviewed-By: Ben Noordhuis <info@bnoordhuis.nl> Reviewed-By: Colin Ihrig <cjihrig@gmail.com>
This provides more information when encountering a syntax or similar error when executing a file with require().