chore: fix flaky TestCacheGetNoDate race (#31687)

This commit is contained in:
andig 2026-07-11 12:39:30 +02:00 • committed by GitHub
parent cc0b5acafb
commit 8f570f84c1
No known key found for this signature in database
GPG key ID: B5690EEEBB952194

View file

@ -31,9 +31,11 @@ func (h *httpHandler) ServeHTTP(w http.ResponseWriter, req *http.Request) {
panic(err)
}
defer conn.Close()
// increment before flushing: the client returns as soon as it reads the body,
// so counting after the flush races with the test asserting on cnt
h.cnt++
fmt.Fprintf(buf, "HTTP/1.1 200 OK\r\nContent-Type: text/html\r\nContent-Length: %d\r\n\r\n%s", len(h.val), h.val)
buf.Flush()
h.cnt++
return
}