Skip to content

Conversation

legendecas
Copy link
Member

Expose hasTopLevelAwait and getHasAsyncGraph on
vm.SourceTextModule.

getHasAsyncGraph requires the module to be instantiated first.

Fixes: #59656

Expose `hasTopLevelAwait` and `getHasAsyncGraph` on
`vm.SourceTextModule`.

`getHasAsyncGraph` requires the module to be instantiated first.
@nodejs-github-bot nodejs-github-bot added needs-ci PRs that need a full CI run. vm Issues and PRs related to the vm subsystem. labels Sep 12, 2025
Copy link

codecov bot commented Sep 12, 2025

Codecov Report

✅ All modified and coverable lines are covered by tests.
✅ Project coverage is 88.27%. Comparing base (22a864a) to head (4194e9f).
⚠️ Report is 11 commits behind head on main.

Additional details and impacted files
@@            Coverage Diff             @@
##             main   #59865      +/-   ##
==========================================
+ Coverage   87.76%   88.27%   +0.51%     
==========================================
  Files         702      702              
  Lines      206690   206703      +13     
  Branches    39679    39775      +96     
==========================================
+ Hits       181392   182467    +1075     
+ Misses      17252    16258     -994     
+ Partials     8046     7978      -68     
Files with missing lines Coverage Δ
lib/internal/vm/module.js 96.34% <100.00%> (+0.08%) ⬆️

... and 101 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.

@legendecas legendecas added the request-ci Add this label to start a Jenkins CI on a PR. label Sep 13, 2025
@github-actions github-actions bot removed the request-ci Add this label to start a Jenkins CI on a PR. label Sep 13, 2025
@nodejs-github-bot
Copy link
Collaborator

@@ -920,6 +920,33 @@ to disallow any changes to it.
Corresponds to the `[[RequestedModules]]` field of [Cyclic Module Record][]s in
the ECMAScript specification.

### `sourceTextModule.getHasAsyncGraph()`
Copy link
Member

@joyeecheung joyeecheung Sep 14, 2025

Choose a reason for hiding this comment

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

Does it need to be a method? It seems fine to just make it a getter property, and it would be more consistent with other getter properties (e.g. error requires the module to be errored, but it's still a getter property)

Copy link
Member Author

Choose a reason for hiding this comment

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

This requires the module to be instantiated, and throws before instantiation.

I think throwing in a getter is not a good pattern. Making it a method indicates that this could incur traversal on the dependency graph, and may throw if this is not instantiated.

Comment on lines +931 to +932
Returns `true` if the module has a dependency graph that contains top-level
`await` expressions, otherwise returns `false`.
Copy link
Member

@joyeecheung joyeecheung Sep 14, 2025

Choose a reason for hiding this comment

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

Suggested change
Returns `true` if the module has a dependency graph that contains top-level
`await` expressions, otherwise returns `false`.
Iterates over the dependency graph and returns `true` if any module in its dependencies or
this module itself contains top-level `await` expressions, otherwise returns `false`.
The search may be slow if the graph is big enough.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
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.

Provide SourceTextModule sync versions of link and evaluate methods
4 participants