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
http: superfluous response.WriteHeader call from github.com/felixge/httpsnoop.(*Metrics).CaptureMetrics.func1.1 (capture_metrics.go:53)
I sometimes get this error in my logs when serving static files with http.ServeContent.
Not sure how this happens if the wrapper is working correctly but the logs don't lie. Maybe ServeContent is somehow getting direct access to the underlying writer?
@infogulch I was seeing this error as well on my endpoints served by http.FileServer.
In my case, it was caused by me calling ServeHttp on the handler that I was also passing to CaptureMetrics. I didn't realise that CaptureMetrics runs ServeHttp on the Handler that you pass to it. Removing my additional direct call to ServeHttp on the original handler fixed the issue.
Activity
rmhubbert commentedon Sep 17, 2025
@infogulch I was seeing this error as well on my endpoints served by http.FileServer.
In my case, it was caused by me calling ServeHttp on the handler that I was also passing to CaptureMetrics. I didn't realise that CaptureMetrics runs ServeHttp on the Handler that you pass to it. Removing my additional direct call to ServeHttp on the original handler fixed the issue.
infogulch commentedon Sep 18, 2025
I think this only occurs when serving a file with
http.ServeContent. It consistently shows up in the logs at least once.