test(uploads): pin the deployed idle bound and its unavailable warning (#56)
Gatekeeper review of PR #63 (comment 15139): - the 60 s default is what production runs (cmd/tapir never sets UploadIdleTimeout) and no test covered it; 1 ns, 60 ms or 24 h all left the suite green. Pinned via export_test.go, plus a socket test with the timeout unset that accepts a body with 100 ms gaps (60 ms mutant red). - the "upload idle bound unavailable" warning, the only signal that the control did not apply, is now asserted (removing it goes red). - the deadline clear on io.EOF was redundant (net/http resets the deadline before its background read) and is removed; ADR-033 text corrected (the part can end before the body, so "cleared on clean EOF" did not hold). Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
This commit is contained in:
@@ -172,15 +172,10 @@ type idleDeadlineBody struct {
|
||||
|
||||
func (b *idleDeadlineBody) Read(p []byte) (int, error) {
|
||||
_ = b.rc.SetReadDeadline(time.Now().Add(b.idle))
|
||||
n, err := b.ReadCloser.Read(p)
|
||||
if errors.Is(err, io.EOF) {
|
||||
// The body is complete: disarm, so the deadline cannot fire on the server's own
|
||||
// background read while the handler is still probing the file. On any other error
|
||||
// it stays armed: net/http drains an unread remainder before replying, and that
|
||||
// drain must stay bounded too.
|
||||
_ = b.rc.SetReadDeadline(time.Time{})
|
||||
}
|
||||
return n, err
|
||||
// Never cleared here: net/http clears the read deadline itself before its background
|
||||
// read once the handler has the body, and an armed deadline after an error also bounds
|
||||
// net/http's drain of an unread remainder before it replies.
|
||||
return b.ReadCloser.Read(p)
|
||||
}
|
||||
|
||||
// abandoned reports, logs at INFO and answers 499, because the client has already gone: its request
|
||||
|
||||
Reference in New Issue
Block a user