diff --git a/modules/rhino/src/main/java/com/script/rhino/RhinoCompiledScript.kt b/modules/rhino/src/main/java/com/script/rhino/RhinoCompiledScript.kt index f3d52e364..32a8ae393 100644 --- a/modules/rhino/src/main/java/com/script/rhino/RhinoCompiledScript.kt +++ b/modules/rhino/src/main/java/com/script/rhino/RhinoCompiledScript.kt @@ -89,9 +89,11 @@ internal class RhinoCompiledScript( } override suspend fun evalSuspend(scope: Scriptable): Any? { - val cx = Context.enter() + val cx = Context.enter() as RhinoContext var ret: Any? withContext(VMBridgeReflect.contextLocal.asContextElement()) { + cx.allowScriptRun = true + cx.recursiveCount++ try { try { ret = cx.executeScriptWithContinuations(script, scope) @@ -126,6 +128,8 @@ internal class RhinoCompiledScript( } catch (var14: IOException) { throw ScriptException(var14) } finally { + cx.allowScriptRun = false + cx.recursiveCount-- Context.exit() } }