Created
July 12, 2012 02:58
-
-
Save kevinohara80/3095399 to your computer and use it in GitHub Desktop.
setTimeout infinite loop
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
var vm = require('vm'); | |
var code = function run() { | |
for(var i=0; i<Infinity; i++) { | |
i++; | |
} | |
}; | |
var sandbox = { | |
setTimeout: setTimeout | |
} | |
code = 'setTimeout(function(){throw new Error(\'timeout\')}, 2000);' + ' \n' + code; | |
code = code + '\nrun();'; | |
console.log(code); | |
var script = vm.createScript(code); | |
script.runInNewContext(sandbox); |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment