spin
spin copied to clipboard
Timing out
Should there be a default timeout for components?
I see 3 "levels" of implementation for this:
-
Timeouts only trigger while wasm instructions are actively running.
- This should be relatively easy to implement with e.g. https://docs.rs/wasmtime/latest/wasmtime/struct.Store.html#method.set_epoch_deadline but can only interrupt at "certain points" (e.g. function entry/exit, loop headers) within wasm
-
Above plus timeout in spin-provided functions (e.g. outbound http).
- Requires somehow passing a "deadline" through to those imports and implementing timeout where relevant (e.g. https://docs.rs/reqwest/latest/reqwest/struct.RequestBuilder.html#method.timeout)
-
Above plus timeout in other cases (wasi functions).
- The only way I can think to do this with sync wasmtime is with signal handlers, but that seems really difficult/messy to get right and especially hard to implement in Windows.
- Using async wasmtime I think makes this fairly straightforward; timing-out the top level entrypoint should cause all the other tasks to recursively drop
I expect the first level to be a really good starting point for this.