Open
Description
new vm.Script()
only evaluates cachedData once when called multiple times with the same js-code. It uses an undocumented, internal cache.
- 16.3.0:
- Darwin XXXXXXX 19.6.0 Darwin Kernel Version 19.6.0: Thu May 6 00:48:39 PDT 2021; root:xnu-6153.141.33~1/RELEASE_X86_64 x86_64 i386 MacBookPro15,1 Darwin:
- vm:
What steps will reproduce the bug?
run the following code in a file or repl:
const vm = require('vm');
const b = Buffer.alloc(0);
console.log(new vm.Script("", {cachedData: b});
console.log(new vm.Script("", {cachedData: b});
Reproducible: always
What is the expected behavior?
Script { cachedDataRejected: true }
Script { cachedDataRejected: true }
What do you see instead?
Script { cachedDataRejected: true }
Script { cachedDataRejected: false }
Additional information
Also reproducible in versions as far back as NodeJs 8.16 and on Linux