[Feature Request] Execution Timeout for Scripts


As described in the discussion-thread, it would be nice to specifiy a timeout for executing scripts.

I think there are ways to achieve this as you showed in the thread, but an integration could be useful, because it makes it easier to prevent scripts from running infinitly (when you don't know what scripts come in) or just to define a maximum runtime for a single script.

Maybe this could be done as a global option for the actual instance of the engine or as an optional parameter when calling engine.Execute(...) for example.
Closed May 27, 2015 at 9:16 PM by jamesnw
Feature now exists in the current development branch. Call {V8Engine}.TerminateExecution() from any thread to terminate a running script.


wangjia184 wrote Feb 2, 2015 at 6:10 AM

+1 vote

There is a 8::V8::TerminateExecution method, doc is here
Forcefully terminate the current thread of JavaScript execution in the given isolate.
This method can be used by any thread even if that thread has not acquired the V8 lock with a Locker object.
V8.NET could export this method so that application has control to terminate a long run javascript

jamesnw wrote May 27, 2015 at 9:43 PM

In addition, I just added a new 'timeout' parameter to the 'Execute()' methods on the engine to help abort long running scripts.

jamesnw wrote May 27, 2015 at 10:09 PM

Added '{InternalHandle}.WasTerminated' so the caller will know if a handle is the result of a completed script execution. Returns true if the script is forcefully terminated by calling '{V8Engine}.TerminateExecution()' (includes timeouts).