From 8f570f84c11e0fc1f647e42e1a7a0a1a9cfee20f Mon Sep 17 00:00:00 2001 From: andig Date: Sat, 11 Jul 2026 12:39:30 +0200 Subject: [PATCH] chore: fix flaky TestCacheGetNoDate race (#31687) --- plugin/http_test.go | 4 +++- 1 file changed, 3 insertions(+), 1 deletion(-) diff --git a/plugin/http_test.go b/plugin/http_test.go index 06e78986e..4d921adbf 100644 --- a/plugin/http_test.go +++ b/plugin/http_test.go @@ -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 }