You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
{{ message }}
Repository navigation
Timout setting does not seem to have any effect #392
Describe the bug
The timeout setting does not terminate long running scripts.
To Reproduce
Run the following code (its the example from the readme just simplified and with a long running loop added):
use rustyscript::{Module,Runtime,RuntimeOptions,Undefined, json_args};use std::{error::Error, time::Duration};fnmain() -> Result<(),Box<dynError>>{let module = Module::new("test.js"," for(let i = 0; i < 1000000000000; i++) {} ",);letmut runtime = Runtime::new(RuntimeOptions{timeout:Duration::from_millis(50),default_entrypoint:Some("load".to_string()),
..Default::default()})?;let module_handle = runtime.load_module(&module)?;
runtime.call_entrypoint::<Undefined>(&module_handle,json_args!(2))?;Ok(())}
The program runs for however long it takes to complete the loop. But shouldnt it be terminated after 50ms?
Expected behavior
Deno should be terminated after 50ms of runtime.
Additional context
Im running the currently lates version 0.12.3
Also: How should the timeout function in the first place? when the first call to runtime.call_entrypoint takes 40ms and then we call it again and it again takes 40ms. should that terminate deno or not?
For anybody coming across the same issue. Heres my workarround:
When deno runs something like while(true) {} it never yields controll back to tokio. So the current thread is just toast forever. The only way ive found arround this is to have IsolateHandle to the v8 in another thread and to invoke terminate_execution() on that. That will stop the infinite loop and free the thread to handle the situation.
The v8 handle can be obtained with rustyscript_runtime.deno_runtime().v8_isolate().thread_safe_handle().
I came accross this by reading this thread: https://users.rust-lang.org/t/how-to-kill-a-thread/96422
@TimoLehnertz , I followed the thread you linked but didn't quite understand how to use it with RustyScript. Is is the case that one directly have to use v8 or deno? If you have, could you please share code snippet that works with RustyScript?
Activity
TimoLehnertz commentedon Sep 7, 2025
For anybody coming across the same issue. Heres my workarround:
When deno runs something like
while(true) {}it never yields controll back to tokio. So the current thread is just toast forever. The only way ive found arround this is to have IsolateHandle to the v8 in another thread and to invoketerminate_execution()on that. That will stop the infinite loop and free the thread to handle the situation.The v8 handle can be obtained with
rustyscript_runtime.deno_runtime().v8_isolate().thread_safe_handle().I came accross this by reading this thread: https://users.rust-lang.org/t/how-to-kill-a-thread/96422
sbjoshi commentedon Jan 7, 2026
@TimoLehnertz , I followed the thread you linked but didn't quite understand how to use it with RustyScript. Is is the case that one directly have to use v8 or deno? If you have, could you please share code snippet that works with RustyScript?