-
-
Notifications
You must be signed in to change notification settings - Fork 401
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Cancel/Interrupt active evaluation #3442
Comments
There isn't a hook to do this at the moment, but we have plans to support this. The simplest API I can think of is a way to set a flag for the |
cool.
yeah, this is exactly what I'm looking for, like |
Alright, I'll put this on our backlog then. |
It's difficult to use Boa for running untrusted third-party code without a way to interrupt eval. I appreciate the simplicity and effectiveness of rquickjs's set_interrupt_handler method for handling this issue. It's a great solution for many use cases. Here's an example showing how a timeout could be implemented using set_interrupt_handler: let timestamp_now = std::time::SystemTime::now();
rt.set_interrupt_handler(Some(Box::new(move || {
if let Ok(elapsed) = timestamp_now.elapsed() {
if elapsed.as_millis() > 1000 {
return true;
}
}
false
}))); |
feature
I would like to be able to cancel an evaluation (or
JsValue::call
) after a certain timeout.Perhaps this is already possible, but I wasn't able to find it.
boja for example has
interrupts
:https://github.com/dop251/goja/blob/b396bb4c349df65109dea3df00fb60f6a044950d/runtime.go#L1474C9-L1482
my motivation for this is to have the option to terminate a (malicious) evaluation for example
while(1) {}
Example code
Give a code example that should work after the implementation of this feature.
The text was updated successfully, but these errors were encountered: