This code disregards the timeout and hangs the process:
'use strict'
const {VM} = require('vm2')
const vm = new VM({
timeout: 5000,
})
console.log('Runs')
vm.run('Promise.resolve(42).then(() => {while(true) {}})') // hangs the process
setImmediate(console.log, 'Will never run')
And Promise can't be easily disabled: #74.
Readme.md
IMPORTANT: Timeout is not effective for NodeVM so it is not immune to while (true) {} or similar evil.
@awiebe except, I'm using VM
, not NodeVM
.
Unfortunately, this is another limitation of node's timeout feature - it doesn't work for asynchronous calls, even if they're running in the sandbox.
This issue has been automatically marked as stale because it has not had recent activity. It will be closed if no further activity occurs. Thank you for your contributions.