You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
{{ message }}
Repository navigation
TestServesAShareThroughCaddy races under -race (also on main) #100
TestServesAShareThroughCaddy (internal/web/share_serve_test.go) sometimes fails under -race with "race detected during execution of test". It does so on main too, so it isn't tied to any PR.
How to reproduce
go test -race -count=30 -run TestServesAShareThroughCaddy ./internal/web
The read is in Caddy's reverse_proxy (modules/caddyhttp/reverseproxy/reverseproxy.go:1368, via net/http/server.go:1145) while it serves the share's request through php_fastcgi. The call chain passes through flock/internal/web.shareHandler.ServeHTTP (internal/web/share.go:140), under encode and headers. The other side of the race is in the same request's handling.
So the share handler's response-writer wrapping (the Vite tag rewrite) and Caddy's proxy look like they touch the same request or response state from two goroutines.
Possible cause
The rewrite in shareHandler may read or replace the response writer (or the request's headers) while reverse_proxy is still streaming in another goroutine, e.g. the buffered writer being inspected before the upstream copy has finished. A first step would be the full race report from -race -count=30 with GORACE=halt_on_error=1.
Fix in #102: the handler now gets its own copy of the headers while a page is rewritten, so reverse_proxy's trailers no longer touch the response from another goroutine. It comes with a test that catches the race every run without the fix.
Activity
omarabulkhair-66 commentedon Nov 4, 2026
Fix in #102: the handler now gets its own copy of the headers while a page is rewritten, so
reverse_proxy's trailers no longer touch the response from another goroutine. It comes with a test that catches the race every run without the fix.fix(web): keep a share's rewritten page headers off the handler's gor…