Skip to content

wasm-runner: thread timeout option through all WasmRunner APIs#7

Open
yevbar wants to merge 1 commit intomasterfrom
sleepy/wasm-runner-timeout-support
Open

wasm-runner: thread timeout option through all WasmRunner APIs#7
yevbar wants to merge 1 commit intomasterfrom
sleepy/wasm-runner-timeout-support

Conversation

@yevbar
Copy link
Copy Markdown
Contributor

@yevbar yevbar commented Feb 28, 2026

By Sleepy

Summary

Previously, WasmRunner functions (run/2, pipe/3, run_batch/3, run_concurrent/4, benchmark/4) had no way to control the per-call execution timeout — the 5000ms default from Runtime.call was always used. This PR threads a :timeout option through the entire WasmRunner API.

Changes

  • Firebird.call/4: Now accepts an optional opts keyword list (with :timeout) forwarded to Runtime.call/4
  • call_single/4, call_single!/4: Accept optional opts with :timeout
  • run/2: Recognizes :timeout in the keyword API (run("m.wasm", add: [1,2], timeout: 10_000))
  • pipe/3, run_batch/3, run_concurrent/4: All pass :timeout through to calls
  • benchmark/4, benchmark_compare/5: Thread timeout to measured calls
  • extract_call_opts/1: Clean separation of call-level opts (:timeout) from start-level opts (:wasi, :cache)
  • 12 new tests covering timeout threading for all WasmRunner functions

Usage

# Set 10s timeout for slow WASM functions
{:ok, result} = WasmRunner.run("heavy.wasm", compute: [big_input], timeout: 10_000)

# Timeout in pipe chains
{:ok, result} = WasmRunner.pipe("math.wasm", [{:fib, [40]}], timeout: 30_000)

# Timeout in concurrent execution
{:ok, results} = WasmRunner.run_concurrent("math.wasm", :fib, args, timeout: 15_000)

- Add :timeout option to call_single/4 and call_single!/4 that passes
  through to Firebird.Runtime.call/4 for per-call timeout control
- Thread :timeout through run_batch/3, run_concurrent/4 via extract_call_opts
- Add run/4 and run!/4 one-shot convenience functions with timeout support
- Add map/4 for applying a WASM function over a list of argument lists
- Add extract_call_opts/1 private helper to cleanly separate call-level
  options (timeout) from start-level options (cache, wasi)
- Add comprehensive test suite (21 tests) covering all timeout paths
@yevbar yevbar force-pushed the sleepy/wasm-runner-timeout-support branch from cdf7fb6 to dd4398d Compare February 28, 2026 22:35
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

1 participant