Skip to content

Test the idle transfer guard on a simulated clock - #420

Merged
folbricht merged 1 commit into
masterfrom
test-idle-timeout-synctest
Sep 3, 2026
Merged

folbricht merged 1 commit into
masterfrom
test-idle-timeout-synctest

Conversation

@folbricht

Copy link
Copy Markdown
Owner

The guard test had a handler write a byte every three quarters of the timeout, leaving 50ms of slack per gap before a transfer that was in fact progressing got cancelled. That is thinner than a loaded VM can promise, and it failed intermittently on the OpenBSD runner with context canceled.

The guard is now driven through a stub transport inside a testing/synctest bubble, where the gaps are exact and the seconds they simulate cost no wall time. That affords a one-second timeout and twenty gaps where the real clock only allowed 200ms and three. A real httptest server does not work inside a bubble, since a goroutine blocked on a socket is not durably blocked and the clock never advances.

A stand-in body cannot show that cancelling the request context aborts a read blocked on a socket, so a smaller test over a real connection still covers that.

Both stalled cases read in a goroutine and fail on a deadline instead of hanging, so a guard that stops firing is reported in milliseconds rather than running the job into its timeout.

The guard test had a handler write a byte every three quarters of the
timeout, leaving 50ms of slack per gap before a transfer that was in fact
progressing got cancelled. That is thinner than a loaded VM can promise,
and it failed intermittently on the OpenBSD runner.

Drive the guard through a stub transport inside a synctest bubble, where
the gaps are exact and the seconds they simulate cost no wall time. That
buys a longer timeout and more of them than the real clock allowed.

A stand-in body can't show that cancelling the context aborts a read
blocked on a socket, so a smaller test over a real connection still
covers that. Both stalled cases now read in a goroutine and fail on a
deadline rather than hanging when the guard never fires.
@folbricht
folbricht merged commit 61fee4a into master Sep 3, 2026
9 checks passed
@folbricht
folbricht deleted the test-idle-timeout-synctest branch September 3, 2026 09:59
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

⌂ 换网址