Skip to content

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

Open
wants to merge 3 commits into
base: main
Choose a base branch
from

Conversation

islandryu
Copy link
Member

@islandryu islandryu commented Jun 9, 2025

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.

@nodejs-github-bot nodejs-github-bot added c++ Issues and PRs that require attention from people who are familiar with C++. needs-ci PRs that need a full CI run. vm Issues and PRs related to the vm subsystem. labels Jun 9, 2025
Copy link

codecov bot commented Jun 9, 2025

Codecov Report

All modified and coverable lines are covered by tests ✅

Project coverage is 90.14%. Comparing base (be2120f) to head (904a081).
Report is 34 commits behind head on main.

Additional details and impacted files
@@            Coverage Diff             @@
##             main   #58646      +/-   ##
==========================================
- Coverage   90.15%   90.14%   -0.02%     
==========================================
  Files         636      637       +1     
  Lines      188028   188125      +97     
  Branches    36895    36894       -1     
==========================================
+ Hits       169526   169581      +55     
- Misses      11231    11278      +47     
+ Partials     7271     7266       -5     
Files with missing lines Coverage Δ
src/node_contextify.cc 81.39% <100.00%> (+0.14%) ⬆️

... and 44 files with indirect coverage changes

🚀 New features to boost your workflow:
  • ❄️ Test Analytics: Detect flaky tests, report on failures, and find test suite problems.
  • 📦 JS Bundle Analysis: Save yourself from yourself by tracking and limiting bundle sizes in JS merges.

@Ethan-Arrowood Ethan-Arrowood added the request-ci Add this label to start a Jenkins CI on a PR. label Jun 10, 2025
@github-actions github-actions bot removed the request-ci Add this label to start a Jenkins CI on a PR. label Jun 10, 2025
@nodejs-github-bot
Copy link
Collaborator

@@ -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', () => {
Copy link
Member

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

Copy link
Member Author

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.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
c++ Issues and PRs that require attention from people who are familiar with C++. needs-ci PRs that need a full CI run. vm Issues and PRs related to the vm subsystem.
Projects
None yet
Development

Successfully merging this pull request may close these issues.

ESM syntax detection ignores certain top-level awaits
5 participants