echo icon indicating copy to clipboard operation
echo copied to clipboard

Warn users with debug enabled that middleware errors are not handled

Open apatruni opened this issue 2 years ago • 1 comments

Warn users with debug enabled that middleware errors are not handled

Users may not expect errors thrown in the middleware on the response path flow to be ignored if the response has been committed by a handler

apatruni avatar Dec 30 '22 01:12 apatruni

I have somewhat mixed feeling about it. I understand and see cases when this is useful but same time it would cause potentially a lot of noise for cases when that early-return is totally OK.

There is https://github.com/labstack/echo/blob/f36d5662fbb1850f03c9ac78f02a699a492ecc2d/response.go#L54-L58 and I know from my own experience that it can cause a lot of log lines.

Maybe we should document all methods on echo.Context what "commit" the Response with short block explaining what commiting means to error handling and for example why you should return errors from handler and not c.String(http.StatusBadRequest, "NOPE") sending response.

also. 3 lines above of https://github.com/labstack/echo/blob/f36d5662fbb1850f03c9ac78f02a699a492ecc2d/echo.go#L391 there is short explanation about "commited" response.

aldas avatar Jan 02 '23 19:01 aldas