node
node copied to clipboard
fix: harden check for non-module in vm.modules linker
(node:528088) ExperimentalWarning: VM Modules is an experimental feature and might change at any time
(Use `node --trace-warnings ...` to show where the warning was created)
node:internal/vm/module:306
if (module[kWrap] === undefined) {
^
TypeError: Cannot read properties of undefined (reading 'Symbol(kWrap)')
at ModuleWrap.<anonymous> (node:internal/vm/module:306:19)
at process.processTicksAndRejections (node:internal/process/task_queues:95:5)
Node.js v19.9.0
Repro case:
const vm = require('node:vm');
async function main() {
const myObj = { myProp: '' };
const context = vm.createContext(myObj);
const module = new vm.SourceTextModule('import * as bug from "bug";', { identifier: 'bug', context });
await module.link(function(a,b,c){return});
}
main();
Should we add a test?
Also, cc @nodejs/vm.
@RaisinTen should that be a simple test of the exception type?
I think so, yes.
Have found the relevant test file and am working up the new test function.
Is there a way to run just one of, or a subset of, the tests?
Yea, you can run ./node test/parallel/test-rest-of-the-file-name.js
to run an individual test
Thanks @RaisinTen!
You can also use tools/test.py test/parallel/test-rest-of-the-file-name.js
or e.g. tools/test.py test/parallel/test-repl-*
if you wanted to run all the REPL tests.
@MikeRalphson are you still working on the regression test or can somebody else pick this up?
Landed in https://github.com/nodejs/node/commit/d1d5da22e4e699a8e32f3fa2a28f53a296eaec40.