- Version:
10.2.1
- Platform:
Darwin Simens-MacBook-Pro.local 17.4.0 Darwin Kernel Version 17.4.0: Sun Dec 17 09:19:54 PST 2017; root:xnu-4570.41.2~1/RELEASE_X86_64 x86_64
- Subsystem:
vm
According to the docs, you should be able to pass timeout when doing new Script. This seemingly does not work.
Running the following snippet will successfully throw an error after one second:
const vm = require('vm');
const script = new vm.Script('while(true){}');
script.runInContext(vm.createContext(), {timeout: 1000});
The following will not:
const vm = require('vm');
const script = new vm.Script('while(true){}', {timeout: 1000});
script.runInContext(vm.createContext());
I did some digging (which might not be useful at all), and to my untrained eyes it looks like new Script constructor ignores timeout argument:
|
const { |
|
filename = 'evalmachine.<anonymous>', |
|
lineOffset = 0, |
|
columnOffset = 0, |
|
cachedData, |
|
produceCachedData = false, |
|
[kParsingContext]: parsingContext |
|
} = options; |
Reported in jsdom/jsdom#2238, /cc @TimothyGu
10.2.1Darwin Simens-MacBook-Pro.local 17.4.0 Darwin Kernel Version 17.4.0: Sun Dec 17 09:19:54 PST 2017; root:xnu-4570.41.2~1/RELEASE_X86_64 x86_64vmAccording to the docs, you should be able to pass
timeoutwhen doingnew Script. This seemingly does not work.Running the following snippet will successfully throw an error after one second:
The following will not:
I did some digging (which might not be useful at all), and to my untrained eyes it looks like
new Scriptconstructor ignorestimeoutargument:node/lib/vm.js
Lines 45 to 52 in 9461f32
Reported in jsdom/jsdom#2238, /cc @TimothyGu