Uh oh!
There was an error while loading. Please reload this page.
errors: print original exception context - #33491
Conversation
devsnek
commented
May 21, 2020
As a general rule, v8::Message is generated from the location of throw, and the error's stack is generated from the location of the error. The v8::Message might sometimes point to the error location instead if it failed to figure out the throw location. |
bcoe
commented
May 21, 2020
@devsnek do you think we should be clever, and even just grep for the |
devsnek
commented
May 21, 2020
@bcoe i think its okay to use the error position. alternatively, you could store the message position info on the error in c++ (like how we store decorations) so its available in the js prepareStackTrace callback. |
bnoordhuis
left a comment
There was a problem hiding this comment.
As a general observation, having an environment-wide flag that toggles the behavior doesn't seem like a good idea. Wouldn't you want to distinguish on whether the script contains a source map URL or not?
You can query the v8::Message object to find out if it has one:
constbool has_source_map_url =
!message->GetScriptOrigin().SourceMapUrl().IsEmpty();Uh oh!
There was an error while loading. Please reload this page.
Uh oh!
There was an error while loading. Please reload this page.
Uh oh!
There was an error while loading. Please reload this page.
Uh oh!
There was an error while loading. Please reload this page.
bcoe
commented
May 22, 2020
@bnoordhuis It does, however, present the issue that if you haven't run a file with Should we check both values (whether source maps are enabled, and whether the script has a source map), and only annotate the error in |
bcoe
commented
May 22, 2020
@bnoordhuis using your suggestion as a starting point, we now only apply the new
|
Uh oh!
There was an error while loading. Please reload this page.
This comment has been minimized.
This comment has been minimized.
This comment has been minimized.
This comment has been minimized.
This comment has been minimized.
This comment has been minimized.
nodejs-github-bot
commented
May 23, 2020
BridgeAR
left a comment
There was a problem hiding this comment.
LGTM. Just left a suggestion to improve unicode support and maybe another test file was meant to be added?
Uh oh!
There was an error while loading. Please reload this page.
Uh oh!
There was an error while loading. Please reload this page.
bcoe
commented
May 23, 2020
@BridgeAR I opted for using fixture based testing, my thinking being that it's actually a pretty elegant way to assert against the whole stack output. tldr; those are tabs in >consttext=fs.readFileSync('test/message/source_map_reference_error_tabs.out','utf8')undefined>text'*tabs.coffee:26\n'+'\talert "I knew it!"\n'+'\t^\n'+ |
bcoe
commented
May 23, 2020
@BridgeAR can you recommend an error message we could throw that would exercise your unicode improvements, I think this would be a great addition to the test suite. Well I'm extending on the test suite, any thoughts on a transpiler I haven't used yet 😆 We've used babel, TypeScript, uglify, CoffeeScript, Istanbul. |
BridgeAR
commented
May 23, 2020
@bcoe I mostly use the following characters to verify unicode support:
Using these in the error message should be sufficient. |
Uh oh!
There was an error while loading. Please reload this page.
@BridgeAR take a look 👍 I noticed that it's actually more accurate with source maps than without now (the message displayed for |
bnoordhuis
left a comment
There was a problem hiding this comment.
LGTM % comments. Nice work, @bcoe.
Uh oh!
There was an error while loading. Please reload this page.
Uh oh!
There was an error while loading. Please reload this page.
Uh oh!
There was an error while loading. Please reload this page.
Uh oh!
There was an error while loading. Please reload this page.
dae507e to
a0b9de9Compare
BridgeAR
left a comment
There was a problem hiding this comment.
Awesome work! Still LGTM, just left two nits.
Uh oh!
There was an error while loading. Please reload this page.
Uh oh!
There was an error while loading. Please reload this page.
This comment has been minimized.
This comment has been minimized.
This comment has been minimized.
This comment has been minimized.
When --enable-source-maps is set, the error context displayed above the stack trace now shows original source rather than transpiled.
This comment has been minimized.
This comment has been minimized.
nodejs-github-bot
commented
May 25, 2020
When --enable-source-maps is set, the error context displayed above the stack trace now shows original source rather than transpiled. PR-URL: #33491 Reviewed-By: Anna Henningsen <anna@addaleax.net> Reviewed-By: Ruben Bridgewater <ruben@bridgewater.de> Reviewed-By: Ben Noordhuis <info@bnoordhuis.nl>
bcoe
commented
May 25, 2020
Landed in 458677f |
@bcoe would you mind opening a manual backport for this into |
When --enable-source-maps is set, the error context displayed above the stack trace now shows original source rather than transpiled. Backport-PR-URL: nodejs#37700 PR-URL: nodejs#33491 Reviewed-By: Anna Henningsen <anna@addaleax.net> Reviewed-By: Ruben Bridgewater <ruben@bridgewater.de> Reviewed-By: Ben Noordhuis <info@bnoordhuis.nl>
When --enable-source-maps is set, the error context displayed above the stack trace now shows original source rather than transpiled. Backport-PR-URL: #37700 PR-URL: #33491 Reviewed-By: Anna Henningsen <anna@addaleax.net> Reviewed-By: Ruben Bridgewater <ruben@bridgewater.de> Reviewed-By: Ben Noordhuis <info@bnoordhuis.nl>
When --enable-source-maps is set, the error context displayed above the stack trace now shows original source rather than transpiled. Backport-PR-URL: #37700 PR-URL: #33491 Reviewed-By: Anna Henningsen <anna@addaleax.net> Reviewed-By: Ruben Bridgewater <ruben@bridgewater.de> Reviewed-By: Ben Noordhuis <info@bnoordhuis.nl>
When --enable-source-maps is set, the error context displayed
above the stack trace now shows original source rather than
transpiled.
When
--enable-source-mapsis set, annotate the top of the stack trace with the original source, rather than the ugly transpiled source:before:
after:
Open questions
The logic in
node_errors.ccis a little magical to me, specifically I'm trying to figure out how it's placing the^under thethrow, rather than under theError(which is where the stack trace points).@addaleax I know you've also worked in this file, any thoughts (maybe this is an issue we don't care about).
Checklist
make -j4 test(UNIX), orvcbuild test(Windows) passes