rubyjs / therubyracer

Embed the V8 Javascript Interpreter into Ruby
1.66k stars 193 forks source link

Timeout parameter does not work with .call() #395

Closed seanmakesgames closed 10 months ago

seanmakesgames commented 8 years ago

The following code soft-locks ruby. I have to kill -9 it to get it to stop. Timeout works fine when I run it inside of eval().

            ctx = V8::Context.new({timeout: timeout_seconds*1000})
            ctx[:db] = DatabaseConnection.new

            Timeout::timeout(timeout_seconds) {
                ctx.eval(code_to_execute) // includes while(true); inside of SCRIPTCALL_TOP_LEVEL

                result["retval"] = ctx[:SCRIPTCALL_TOP_LEVEL].call(
                    {
                        :caller => @current_user.name,
                        :calling_script => nil,
                        :this_script => params["script_name"]
                    },
                    RunProcessor.process_args(params["args"])
                )
            }