spin icon indicating copy to clipboard operation
spin copied to clipboard

Timing out

Open radu-matei opened this issue 2 years ago • 2 comments

Should there be a default timeout for components?

radu-matei avatar Feb 01 '22 17:02 radu-matei

I see 3 "levels" of implementation for this:

  1. 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
  2. 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)
  3. 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

lann avatar Mar 21 '22 19:03 lann

I expect the first level to be a really good starting point for this.

radu-matei avatar Apr 19 '22 14:04 radu-matei