nodejs: Is it possible to eval js code using runInNewContext and limit its execution time by a timeout?

Viewed 4755

I'd like to execute an untrusted js code using runInNewContext in node.js but as far as I see there is no way to limit its execution time. Also it is a sync operation. is there a way to set timeout on it or async version of it that will allow me to control its execution from 'outside'?

UPDATE: running in an external process is no good:

  • takes too much resources
  • more importantly, I need the code to have access to my data/code though sandbox environment
3 Answers
Related