Timeout is handled in a sandboxed formatter using a time limited thread. This requires Java. It's not possible to start new threads from JavaScript. Trying leads to the following exception:
java.util.concurrent.ExecutionException: java.lang.IllegalStateException: Multi threaded access requested by thread Thread[pool-1-thread-1,5,main] but is not allowed for language(s) js.
While this seems to be a GraalVM related limitation and not a Nashorn specific one, it make sense to keep the JavaScript code compatible with GraalVM because it's a natural choice when using newer Java versions.
As a result the timeout feature is only available in the standalone formatter.
closes #244 .
Timeout is handled in a sandboxed formatter using a time limited thread. This requires Java. It's not possible to start new threads from JavaScript. Trying leads to the following exception:
see
While this seems to be a GraalVM related limitation and not a Nashorn specific one, it make sense to keep the JavaScript code compatible with GraalVM because it's a natural choice when using newer Java versions.
As a result the timeout feature is only available in the standalone formatter.