Closed bengarrett closed 2 months ago
This probably happens when your browser makes a request, it is still being served by the server and browser decides to abort the request by closing the connection. at that point server is at some function/method that tries to write into that connection (probably c.Render(http.StatusOK, name, data)
) without knowing yet that the connection has been closed and gets that error.
Thanks, I guess it's best to handle the specific error.
Next time it happens I'll check the browser console log, network connections to see if it has cancelled any part of the request.
I managed to isolate and recreate this issue. It specifically happens when using a live reloader like Air and spamming the refresh tab button.
For anyone who searches this, handing the error using errors.Is(err, syscall.EPIPE)
solved it for me.
func InternalErr(c echo.Context, uri string, err error) error {
if errors.Is(err, syscall.EPIPE) {
fmt.Fprintf(io.Discard, err)
return nil
}
const code = http.StatusInternalServerError
logger := zaplog.Debug()
if err != nil {
logger.Error(err) # line 166
}
Issue Description
Hi, thanks for the great work with Echo, it's much appreciated! I seem to be suffering an random issue with the session middleware that causes an occasional critical error.
Unfortunately I can not recreate it but the error pops up on browser page loads. It may have something to do with server/client connection pools? https://dev.to/mstryoda/golang-what-is-broken-pipe-error-tcp-http-connections-and-pools-4699
1st occurrence
2nd occurrence
Error trace
Checklist
Working code to debug
/home/ben/github/myapp/handler/app/error.go:166
/home/ben/github/myapp/handler/app/dirs.go:192
/home/ben/github/myapp/handler/router.go:208
Version/commit
echo/v4@v4.12.0
echo-contrib@v0.17.1