-
Notifications
You must be signed in to change notification settings - Fork 30.6k
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
Not fully linked vm.Module throws errors from C++ when instantiated #18571
Comments
@TimothyGu what's the status on this? Did you proceed with it? |
@ryzokuken No… Unassigning myself. /cc @devsnek |
There is now node_errors.h so we could also throw the error with a hard-coded message from the C++ side instead of using a try-catch hack. |
Ping @TimothyGu ... does this need to remain open? |
Yes. The error is the same as the OP, though the script is now // test.js
const neverLinked = new vm.SourceTextModule('import "nonexistent";');
// Note: `await` intentionally omitted as the returned promise will never resolve.
neverLinked.link(() => new Promise(() => {}));
const main = new vm.SourceTextModule('import "neverLinked";');
await main.link(() => neverLinked);
main.instantiate();
|
@joyeecheung I think this issue can be closed since the vm.Module API has been changed |
Fixed by #37598 |
Executing
with
--experimental-vm-modules
throwswhich does not have the error code that is present on all other errors thrown by
instantiate()
. In comparison,throws an error with a proper error code:
The thrown error comes from
node/lib/internal/vm/Module.js
Line 170 in 9974d6a
which due to restrictions on how V8's C++ API operates makes it inconvenient to add the error code. The way to fix this would be to wrap a
try
-catch
block aroundnode/lib/internal/vm/Module.js
Line 170 in 9974d6a
to throw a proper
errors.Error
. The error message can be hard-coded asLinked dependencies must all be linked before instantiation
, since this should be the only possible error thrown from this line.See also #18106.
The text was updated successfully, but these errors were encountered: