-
Notifications
You must be signed in to change notification settings - Fork 30.2k
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
src: fix undefined script name in error source #56502
base: main
Are you sure you want to change the base?
Conversation
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 with a suggestion.
src/node_errors.cc
Outdated
const char* filename_string = *filename; | ||
std::string filename_string; | ||
if (message->GetScriptResourceName()->IsUndefined()) { | ||
filename_string = "<unnamed_script>"; |
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.
filename_string = "<unnamed_script>"; | |
filename_string = "<anonymous>"; |
Which is what Chrome DevTools use, or I think <anonymous_script>
is somewhat easier to understand. It would be even clearer if it's <eval_script>
but I suspect this can be hit in other non-eval cases so can be tricky.
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 didn't use <anonymous>
because it has been used to refer to anonymous functions in the error stacks just below the sources. I think it could be confused with anonymous scripts and functions.
<anonymous_script>
looks good to me.
Codecov ReportAll modified and coverable lines are covered by tests ✅
Additional details and impacted files@@ Coverage Diff @@
## main #56502 +/- ##
==========================================
- Coverage 89.12% 89.12% -0.01%
==========================================
Files 662 662
Lines 191555 191560 +5
Branches 36856 36854 -2
==========================================
- Hits 170730 170721 -9
- Misses 13696 13701 +5
- Partials 7129 7138 +9
|
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 with @joyeecheung's suggestion
3f9f17c
to
996e2c3
Compare
If an error is not caught, the file name and source code line where the error was thrown is printed. However, for unnamed eval scripts, a placeholder instead of
undefined
should be print:This PR prints a placeholder
<anonymous_script>
for such errors: