Skip to content

feat: per-call timeout — Client::call_with_timeout + Transport::recv_timeout - #7

Merged
Kinflou merged 1 commit into
mainfrom
feat/runtime-timeout
Sep 1, 2026
Merged

feat: per-call timeout — Client::call_with_timeout + Transport::recv_timeout#7
Kinflou merged 1 commit into
mainfrom
feat/runtime-timeout

Conversation

@Kinflou

@Kinflou Kinflou commented Sep 1, 2026

Copy link
Copy Markdown
Member

The runtime half of per-call settings (@timeout_ms, §4.4): give up waiting for the response after a deadline.

Transport::recv_timeout(buf, Duration) -> Result<bool, _> Ok(false) once the deadline passes. Default blocks (ignores the timeout) — a clock-less no_std transport still works, it just can't honour a per-call deadline.
InMemory::recv_timeout over mpsc::Receiver::recv_timeout
Tcp::recv_timeout set_read_timeout around the length + body reads. A mid-frame timeout desyncs the stream, so a timed-out Tcp call is fatal to the connection — drop the Tcp (documented).
Client::call_with_timeout(call_id, &P, Duration) maps a timed-out recv to RuntimeError::Timeout (the variant existed; nothing produced it until now). call and call_with_timeout share one private request_response helper.

notify (one-way) takes no timeout — nothing to wait for.

Test

tests/timeout_roundtrip.rs — an Echo stand-in: one call_with_timeout with no server times out at ~50ms → RuntimeError::Timeout; one answered before a 5s deadline succeeds. All feature configs green (--no-default-features, --features alloc, default); no new clippy warnings.

Next

comline-codegen-rust reads @timeout_ms from Function.parameters and emits call_with_timeout(i, &params, Duration::from_millis(N)) for that function; no annotation → call as today.

…_timeout

For a `@timeout_ms` function annotation: give up waiting for the response
after a deadline.

- Transport::recv_timeout(buf, Duration) -> Result<bool, _> -- `Ok(false)`
  once the deadline passes. Default blocks (ignores the timeout) so a
  clock-less transport still works; `std` impls override it:
  - InMemory -> mpsc recv_timeout
  - Tcp -> set_read_timeout around the length + body reads; a mid-frame
    timeout desyncs the stream, so a timed-out Tcp call is fatal to the
    connection (documented).
- Client::call_with_timeout(call_id, &P, Duration) -> maps a timed-out
  recv to RuntimeError::Timeout (the variant existed, nothing produced it).
  `call` / `call_with_timeout` now share one `request_response` helper.

tests/timeout_roundtrip.rs: an Echo stand-in -- one call with no server
times out (~50ms), one answered before a 5s deadline succeeds. All
feature configs green; no new clippy warnings.
@Kinflou
Kinflou merged commit 0501812 into main Sep 1, 2026
6 checks passed
@Kinflou
Kinflou deleted the feat/runtime-timeout branch September 1, 2026 18:28
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