Open LcritZ opened 5 months ago
We don't have timeouts at the moment, but you can easily use middleware for that (Metering
middleware)
So you can stop execution after certain amount of "gas points" are being exhausted (so this makes sure halting execution happens deterministically).
Here's a full example of how to use Metering middleware in Wasmer: https://github.com/wasmerio/wasmer/blob/main/examples/metering.rs
Adding a timed halt of the wasm process might be interesting as well for the runtime, but is not planned in the short term.
Note: if you are using WASIX, there's actually another way of killing the program, which is by sending a KILL signal to the Wasm process (please let us know if you may be interested in a more detailed example).
Would the middleware or WASIX approaches work for you?
The existing metering middleware allows the host adjust the metering points during the execution. So I would assume it is possible to start the execution with u64::MAX
points and after a time out set the remaining points to 0
. (high level idea, untested)
Thanks for proposing a new feature!
Motivation
we use WASM and choose wamser runtime to support our main program like golang service, loading .wasm file dynamically to do some process. the problem is that, how can we stop the wasmer instance continue to execution when it reach our timeout set in main program. since we hope the wasmer instance won't take up cpu once it is timeout. is there any timeout mechanism in wamser runtime? I cannot find the solution for this, can share it if there is an alternative way, thanks