Skip to content

fix(body): start read_timeout timer when polling next frame - #3118

Open
princejain756 wants to merge 2 commits into
seanmonstar:masterfrom
princejain756:fix-3115-read-timeout-between-reads
Open

princejain756 wants to merge 2 commits into
seanmonstar:masterfrom
princejain756:fix-3115-read-timeout-between-reads

Conversation

@princejain756

Copy link
Copy Markdown

Since #3085, ReadTimeoutBody::poll_frame reset its reused tokio::time::Sleep timer as soon as a frame completed (Poll::Ready) rather than when the caller began polling for the next frame. Any time the caller spent between reads therefore counted against the next read's read_timeout, causing resp.chunk().await to time out after a caller pause even when all data (or EOF) had already arrived.

Changes

  • Track armed: bool on ReadTimeoutBody so the reused Sleep instance is reset at the start of a new frame poll (!*this.armed) and disarmed (*this.armed = false) when this.inner.poll_frame(cx) returns Poll::Ready.
  • Avoid calling Instant::now() on subsequent polls of an already-pending frame while preserving the Sleep allocation reuse from perf(body): reuse tokio::time::Sleep timer via reset() in ReadTimeoutBody #3085.
  • Add read_timeout_ignores_time_between_reads in tests/timeouts.rs.

Fixes #3115

princejain756 and others added 2 commits October 21, 2026 13:31
Since seanmonstar#3085, ReadTimeoutBody::poll_frame reset its reused Sleep timer as
soon as a frame finished rather than when the next frame poll began. Any
caller pause between reads therefore counted against the next read's
read_timeout.

Track whether the timer is armed for an in-progress frame poll so the
reused Sleep is only reset when a new frame poll starts, and disarmed
once inner.poll_frame yields Poll::Ready.

Fixes seanmonstar#3115
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.

read_timeout counts the caller's time between reads since 0.13.5

1 participant