Skip to content

module: always decorate thrown errors - #4287

Closed
mscdex wants to merge 1 commit into
nodejs:masterfrom
mscdex:module-decorate-errors
Closed

module: always decorate thrown errors#4287
mscdex wants to merge 1 commit into
nodejs:masterfrom
mscdex:module-decorate-errors

Conversation

@mscdex

Copy link
Copy Markdown
Contributor

This provides more information when encountering a syntax or similar error when executing a file with require().

@mscdexmscdex added the module Issues and PRs related to the module subsystem. label Dec 15, 2015
@mscdex

Copy link
Copy Markdown
ContributorAuthor

CI is all green except flaky tests and CI issues: https://ci.nodejs.org/job/node-test-pull-request/1001/

@bnoordhuis

Copy link
Copy Markdown
Member

LGTM

@cjihrig

Copy link
Copy Markdown
Contributor

Using the normal workflow, this will cause two arrow messages to be printed. For example:

$ node foo.js /Users/cjihrig/iojs/node/foo.js:1
^
^
/Users/cjihrig/iojs/node/foo.js:1
^
^
SyntaxError: Unexpected token ^
...

Where foo.js just contains a ^.

@cjihrig

Copy link
Copy Markdown
Contributor

From a quick test, it looks like removing the arrow information from ReportException() in node.cc fixes the problem.

@mscdex

Copy link
Copy Markdown
ContributorAuthor

Hrmm... what about adding/checking a "decorated" flag as another hidden value on the error object?

@mscdex
mscdexforce-pushed the module-decorate-errors branch 2 times, most recently from 57a9169 to 490c4b8CompareDecember 15, 2015 20:39
@mscdex

Copy link
Copy Markdown
ContributorAuthor

@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/

@mscdex
mscdexforce-pushed the module-decorate-errors branch from 490c4b8 to fbcb95aCompareDecember 15, 2015 21:10

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

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

Should this use result?

Copy link
Copy Markdown
ContributorAuthor

Choose a reason for hiding this comment

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

Fixed.

@mscdex
mscdexforce-pushed the module-decorate-errors branch 3 times, most recently from 9dc88d1 to ed203d0CompareDecember 16, 2015 03:56
@mscdex

Copy link
Copy Markdown
ContributorAuthor

Incorporated suggestions and CI is green except flaky tests: https://ci.nodejs.org/job/node-test-pull-request/1010/

@cjihrig

Copy link
Copy Markdown
Contributor

LGTM

Comment threadlib/internal/util.js Outdated

Copy link
Copy Markdown
Member

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.)

@jasnell

Copy link
Copy Markdown
Member

semver-minor?

@mscdex
mscdexforce-pushed the module-decorate-errors branch from ed203d0 to ac1633bCompareDecember 17, 2015 22:49
@mscdex

Copy link
Copy Markdown
ContributorAuthor

@bnoordhuis I've made your suggested changes. LGTY now?

Comment threadsrc/node.cc Outdated

Copy link
Copy Markdown
Member

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.

@bnoordhuis

Copy link
Copy Markdown
Member

LGTM with a nit and a suggestion.

This provides more information when encountering a syntax or similar
error when executing a file with require().
@mscdex
mscdexforce-pushed the module-decorate-errors branch from ac1633b to e7ac2fcCompareDecember 17, 2015 23:54
@mscdex

Copy link
Copy Markdown
ContributorAuthor

Updated commit. Last CI run: https://ci.nodejs.org/job/node-test-pull-request/1022/

@mscdex

Copy link
Copy Markdown
ContributorAuthor

@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?

mscdex added a commit that referenced this pull request Dec 19, 2015
This provides more information when encountering a syntax or similar
error when executing a file with require().
Fixes: #4286
PR-URL: #4287
Reviewed-By: Ben Noordhuis <info@bnoordhuis.nl>
Reviewed-By: Colin Ihrig <cjihrig@gmail.com>
@mscdex

Copy link
Copy Markdown
ContributorAuthor

Landed in 18490d3.

@mscdexmscdex closed this Dec 19, 2015
@mscdex
mscdex deleted the module-decorate-errors branch December 19, 2015 19:20
Fishrock123 pushed a commit to Fishrock123/node that referenced this pull request Dec 22, 2015
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>
Fishrock123 added a commit to Fishrock123/node that referenced this pull request Dec 22, 2015
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
@jasnelljasnell added the semver-major PRs that contain breaking changes and should be released in the next major version. label Dec 24, 2015
@jasnell

Copy link
Copy Markdown
Member

Marking as semver-major due to the error handling change. It's not clear if this is major or minor tho. @nodejs/ctc

@jasnelljasnell mentioned this pull request Mar 17, 2016
scovetta pushed a commit to scovetta/node that referenced this pull request Apr 2, 2016
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>
Sign up for freeto join this conversation on GitHub. Already have an account? Sign in to comment

Labels

moduleIssues and PRs related to the module subsystem.semver-majorPRs that contain breaking changes and should be released in the next major version.

Projects

None yet

Development

Successfully merging this pull request may close these issues.

4 participants

@mscdex@bnoordhuis@cjihrig@jasnell