Skip to content
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

Preserve the realm of the promise returned by importModuleDynamically in vm:SourceTextModule #53575

Open
lachrist opened this issue Jun 25, 2024 · 0 comments
Labels
feature request Issues that request new features to be added to Node.js. vm Issues and PRs related to the vm subsystem.

Comments

@lachrist
Copy link

What is the problem this feature will solve?

Dynamic imports in modules created by the vm:SourceTextModule currently return a promise created by the intrinsic Promise of the main realm and not the realm of the module. This can be a problem in practice because realms are commonly used to achieve test case isolation at a cheap performance cost. And these test cases might somehow rely on the identity of the constructor of promises returned by dynamic imports -- eg: https://github.com/tc39/test262/blob/c47b716e8d6bea0c4510d449fd22b7ed5f8b0151/test/language/expressions/dynamic-import/returns-promise.js

What is the feature you are proposing to solve the problem?

The problem comes from importModuleDynamicallyWrap which returns an async function:

function importModuleDynamicallyWrap(importModuleDynamically) {

If we want preserve the promise constructor provided by the user-defined importModuleDynamically , it should use explicit then chaining. NB: I'm not sure there is no other async jump downstream that could cause the same issue.

What alternatives have you considered?

No response

@lachrist lachrist added the feature request Issues that request new features to be added to Node.js. label Jun 25, 2024
@RedYetiDev RedYetiDev added the vm Issues and PRs related to the vm subsystem. label Jun 26, 2024
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
feature request Issues that request new features to be added to Node.js. vm Issues and PRs related to the vm subsystem.
Projects
Status: Awaiting Triage
Development

No branches or pull requests

2 participants