Repository navigation
feat(transport): introduce stream I/O timeouts - #1518
Draft
rvolosatovs wants to merge 5 commits into
Draft
rvolosatovs wants to merge 5 commits into
rvolosatovs wants to merge 5 commits into
Conversation
Add an optional timeout to `frame::Incoming` and `frame::Outgoing`, configured via `with_timeout` and inherited by sub-streams returned by `index`. When set, a read that does not make progress within the timeout fails with `ErrorKind::TimedOut` instead of pending forever, which lets peers drop invocations whose counterpart stops sending data, e.g. a client that sends fewer parameter bytes than the function signature requires and then keeps the stream open. `Outgoing` writes are buffered in a channel drained by a detached egress task, so the write timeout is applied there: egress fails if the underlying connection does not accept any data within the timeout, the result is passed to `on_egress` and subsequent writes, flushes and shutdowns on the stream surface the same error. A peer that stops reading from the connection therefore causes the connection to be released, instead of blocking it forever. The timeout is shared with the egress task through a slot that also holds its waker, so a timeout configured after the writer has already stalled still arms a deadline. The QUIC and WebTransport `on_egress` handlers reset the send stream when egress fails, so that waiting for the peer to stop the stream resolves and the peer observes the failure. Assisted-by: claude:claude-fable-5-1
Add `invoke::IoTimeout` and `invoke::IoTimeoutOwned` wrappers, which apply a read and write timeout to the `Incoming` and `Outgoing` streams returned by `Invoke::invoke`, so that an invocation errors instead of hanging when the server stops responding mid-invocation. This is kept separate from `InvokeExt::timeout`, which still only bounds the `Invoke::invoke` call, since an I/O timeout also bounds the handler's time to first result byte and applies to async sub-streams, which may legitimately outlive the invocation and idle for longer. Assisted-by: claude:claude-fable-5-1
Add `serve::IoTimeout` and `serve::IoTimeoutOwned` wrappers, mirroring the `invoke` ones, which apply a read and write timeout to the `Incoming` and `Outgoing` streams of every accepted invocation. A client that sends fewer parameter bytes than the served function expects and then keeps the connection open previously left the server-side decoder pending forever (#1045); with a timeout the invocation now fails with `ErrorKind::TimedOut` and its resources are released. Likewise, a client that stops reading results no longer blocks the connection forever. Assisted-by: claude:claude-fable-5-1
rvolosatovs
force-pushed
the
feat/transport-io-timeout
branch
from
October 8, 2026 14:09
2d1620e to
e6d507d
Compare
Bound the `Invoke::invoke` call itself in `invoke::IoTimeout`, so that the synchronous parameter write, which happens before the `Outgoing` stream exists, can no longer hang forever when the server stops reading; add a test covering that path. Return from the QUIC and WebTransport `on_egress` handlers right after resetting the send stream on failure, since quinn never wakes `stopped()` for a locally reset stream and the task would otherwise linger until the connection closed. Name the WebTransport stream error codes. Only clone the egress waker when it changed. Document that the read timeout bounds idle gaps, including the time to first byte, that `Incoming::with_timeout` is armed lazily and only inherited by sub-streams indexed afterwards, and that `Outgoing` flushes and shutdowns only report a write timeout that already occurred. Assisted-by: claude:claude-fable-5-1
Clear the `Incoming` read deadline once it fires, so that a read retried after `ErrorKind::TimedOut` gets a fresh window instead of failing immediately on the expired timer forever; add a test. Only report write timeouts from `Outgoing` flushes and shutdowns, so that other background write errors, e.g. a peer that stopped reading after receiving everything it needed, no longer turn a previously successful flush into an error. Reuse `invoke::Timeout` in `invoke::IoTimeout` instead of duplicating it, and use `core::error::Error` in `egress_error`. Document that dropping a pending read does not clear the read deadline, and that `ServeExt::io_timeout` does not bound reads a transport does before yielding an invocation, such as the header read in `frame::Server::accept`. Assisted-by: claude:claude-opus-5-5
rvolosatovs
force-pushed
the
feat/transport-io-timeout
branch
from
October 8, 2026 14:59
abaca76 to
7ee06eb
Compare
This branch has not been deployed
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
closes #1045