I want to use the vm module as a safe way to run external code. It works pretty well, but there is one issue left:
var UNKNOWN_CODE = "while(true){}";
var vm = require("vm");
var obj = {};
var ctx = vm.createContext(obj);
var script = vm.createScript(UNKNOWN_CODE);
script.runInNewContext(ctx);
console.log("finished"); //never executed
Is there any way to cancel the execution (e.g. if it lasts for more than 5s)?
Thanks in advance!