caddyserver / cache-handler

Distributed HTTP caching module for Caddy
Apache License 2.0
269 stars 22 forks source link

text/event-stream Mercure subscribe requests causes a panic #107

Closed silverbackdan closed 4 weeks ago

silverbackdan commented 4 weeks ago

It seems when Mercure is enabled, we want to subscribe to topics, but Souin will panic and crash.

The workaround is to currently bypass the cache for these unsupported requests , and for me this is the expression:

@use_cache expression `
    !header({'Accept': 'text/event-stream'}) &&
    !(header({'Connection': '*Upgrade*', 'Upgrade': 'websocket'}))
`
cache @use_cache

The addition of skipping the cache for websockets wasn't to prevent passing through the cache - I'm not sure if it triggered a panic as well - but I know it shouldn't pass through.

Not sure if it'd make sense to at least detect requests which would cause a panic and skip those.

No great rush whether this should be implemented or not, as the workaround is simple - probably shouldn't crash though.

silverbackdan commented 4 weeks ago

Opened in wrong repo. See https://github.com/darkweak/souin/issues/562