-
-
Notifications
You must be signed in to change notification settings - Fork 31.9k
module: correctly detect top-level await in ambiguous contexts #58646
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
base: main
Are you sure you want to change the base?
Conversation
Codecov ReportAll modified and coverable lines are covered by tests ✅
Additional details and impacted files@@ Coverage Diff @@
## main #58646 +/- ##
==========================================
- Coverage 90.15% 90.06% -0.10%
==========================================
Files 636 640 +4
Lines 188028 188291 +263
Branches 36895 36919 +24
==========================================
+ Hits 169526 169592 +66
- Misses 11231 11399 +168
- Partials 7271 7300 +29
🚀 New features to boost your workflow:
|
@@ -423,3 +423,77 @@ describe('when working with Worker threads', () => { | |||
strictEqual(signal, null); | |||
}); | |||
}); | |||
|
|||
describe('maybe top-level await syntax errors that are not recognized as top-level await errors', () => { |
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.
This test is already too long with too many things mixed together. Can you add the new tests to a new file? https://github.com/nodejs/node/blob/main/doc/contributing/writing-tests.md#how-to-write-a-good-test
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.
Thanks!
I've moved the test to a new file.
src/node_contextify.cc
Outdated
std::array<std::string_view, 2>{// example: `func(await 1);` | ||
"missing ) after argument list", | ||
// example: `if(await 1)` | ||
"SyntaxError: Unexpected"}; |
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.
Did the linter/formatter format the code this way?
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.
Yes, but now that you mention it, it's a weird format.
I've changed the comment's position.
Fixes: #58331
Many syntax errors are incorrectly treated as requiring ESM recompilation, but since they can't be clearly distinguished from top-level await-related errors, the current fix ends up handling them together.
From what I can tell by looking at the issues reported on V8, this appears to be a problem on the V8 side, so I will see if a fix can be made there.
https://issues.chromium.org/issues/40070895#comment1
That said, this patch will be necessary until the issue is resolved in V8.