Repository navigation
tcp: sendTimeoutMs's doc says it's a deadline for each flush, on purpose, and readTimeoutMs's says when its clock runs - #50
Merged
Conversation
…ose, and readTimeoutMs's says when its clock runs (#24) sendTimeoutMs read as a stall timer, "how long a flush may wait on a peer that stopped draining", so a slow peer cut off by a large flush looked like a bug. It is a deadline for the whole flush, and that is wanted: a clock that restarted on progress would let a peer that reads a little now and then hold a flush and its slab open for good. The doc now says so, as ioxide's does, with the way to send a large body to a slow peer: in pieces. readTimeoutMs says when its clock runs: only while a read waits with nothing queued, and a flush restarts it.
This was referenced Nov 8, 2026
Closed
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.
Fixes #24. Docs only.
What was wrong
sendTimeoutMswas documented as "how long a flush may wait on a peer that stopped draining", which reads as a stall timer. It is a deadline for the whole flush: the clock starts when the flush is handed over, and nothing moves it until the flush completes. So a peer that keeps reading, but slowly, is cut off once one flush takes longer than the timeout. #24 measured that: 12 MiB to a peer reading about 0.77 MiB/s, with the timeout at 1 s, got 2.28 MiB through.Why the behavior stays
A clock that restarted on progress, as #24's first two fix options proposed, would let a peer that reads a little now and then hold a flush open for as long as it likes, and with it the connection and the slab holding the body. That's a slow-read attack. A deadline per flush bounds it, and nothing the peer sends restarts that deadline. ioxide made the same choice, and its
SendTimeoutMsdoc says so.What changed
sendTimeoutMs: says it's a deadline for the whole flush and what it defends against. It also says how to send a large body to a slow peer: flush it in pieces, each with its own deadline. The peer then only has to keep up the piece size per timeout, about 1 KiB/s for 64 KiB pieces at the default 60 s.readTimeoutMs: says when its clock runs: only while a read waits with nothing queued, and a flush restarts it. So a handler that is busy, sending or not reading is never timed out by it. It also says the timeout bounds a peer's close after its handler let go, and thatdisableReadTimeouttakes a connection's reads off it.TcpTimeoutTestalready covers the behavior these describe, for examplea server that keeps sending is not waiting on its peeranda handler busy for longer than the read timeout still answers.🤖 Generated with Claude Code