souin icon indicating copy to clipboard operation
souin copied to clipboard

souin middleware doesn't support best practice for error handling in caddy cache handler

Open yuvalman opened this issue 6 months ago • 3 comments

Hi, After consulting with Caddy community about error handling best practices, the souin middleware used by https://github.com/caddyserver/cache-handler, can follow the best practices? Here is the community discussion: https://caddy.community/t/best-practices-for-handling-errors-in-chain-of-custom-modules/31101

In this code: https://github.com/darkweak/souin/blob/master/pkg/middleware/middleware.go#L976-L981

we can see the middleware write bytes and not return nil or HandlerError, which does not follow the best practices (which means the chain will continue to the next middleware, and it's body response ("Internal server error" string) will be flushed to the next middlewares in the chain, which can cause unexpected behavior).

yuvalman avatar Jun 11 '25 13:06 yuvalman

Hi, i also experience this issue.

nikitakogan1994 avatar Jun 30 '25 09:06 nikitakogan1994

I'd really like an update when this ticket will be addressed, important topic to my team

shimongewirtz avatar Jun 30 '25 09:06 shimongewirtz

Following this as well.

charphob avatar Jun 30 '25 09:06 charphob