Skip to content

fix(wasm): reject unenforceable timeouts#2211

Open
chaliy wants to merge 1 commit into
mainfrom
2026-07-26-propose-fix-for-wasm-timeout-issue
Open

fix(wasm): reject unenforceable timeouts#2211
chaliy wants to merge 1 commit into
mainfrom
2026-07-26-propose-fix-for-wasm-timeout-issue

Conversation

@chaliy

@chaliy chaliy commented Jul 26, 2026

Copy link
Copy Markdown
Contributor

Motivation

  • The wasm build previously avoided timer panics by compiling out timeout enforcement, which silently accepted timeoutMs/timeout N and allowed unresolved async callbacks to suspend execution indefinitely. This is an availability/control bypass for callers who rely on timeouts.
  • The change closes the gap by treating unenforceable wall-clock timeouts on single-threaded JS-host wasm as unsupported, failing fast instead of awaiting a future that cannot be preempted.

Description

  • Add a wasm-specific unsupported_timeout_response() and use it from BashTool execution paths so streaming, direct, and execute_with_status calls return an explicit unsupported-timeout ToolResponse (exit code 125) when timeoutMs is supplied on wasm targets.
  • Update ScriptedTool to return unsupported_timeout_response() on wasm when a per-call timeout is requested instead of ignoring the deadline and awaiting orchestration futures.
  • Change the timeout builtin in the interpreter to fail closed on wasm by returning an ExecResult with an explanatory message and exit code 125 without dispatching the inner command when the builtin is given a wall-clock timeout on wasm targets.
  • Update tests and docs: modify the wasm smoke test to assert the unsupported-timeout behaviour; update crates/bashkit-wasm/README.md, specs/browser-package.md, and specs/limitations.md to document the fail-closed contract.

Testing

  • Ran cargo check -p bashkit --target wasm32-unknown-unknown --features scripted_tool,jq and cargo test -p bashkit test_tool_execute_timeout, and the unit test test_tool_execute_timeout passed.
  • Ran cargo clippy (native and wasm-target slices with -- -D warnings) and cargo fmt --check; linters and format checks passed after the changes.
  • Attempted wasm packaging smoke build; cargo build succeeded but wasm-bindgen CLI was not present in the environment so full wasm-bindgen packaging was not executed in this run (adjust local build environment to run bash crates/bashkit-wasm/scripts/build.sh end-to-end).

Codex Task

@cloudflare-workers-and-pages

cloudflare-workers-and-pages Bot commented Jul 26, 2026

Copy link
Copy Markdown

Deploying with  Cloudflare Workers  Cloudflare Workers

The latest updates on your project. Learn more about integrating Git with Workers.

Status Name Latest Commit Preview URL Updated (UTC)
✅ Deployment successful!
View logs
bashkit 4c8be69 Commit Preview URL Jul 26 2026, 10:39 PM

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Projects

None yet

Development

Successfully merging this pull request may close these issues.

1 participant