Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Souin Interfering with Mercure – panic: feature not supported Error #600

Open
g-ra opened this issue Feb 25, 2025 · 1 comment
Open

Souin Interfering with Mercure – panic: feature not supported Error #600

g-ra opened this issue Feb 25, 2025 · 1 comment

Comments

@g-ra
Copy link

g-ra commented Feb 25, 2025

Hi!
I'm encountering a panic: feature not supported error when using Souin alongside Mercure. When trying to subscribe to a topic (Mercure SubscribeHandler), a panic occurs, related to singleflight.
Environment Details:
Souin version v1.6.50
Mercure version v0.18.1
Caddy version v2.9.1
Go version 1.22.10
golang.org/x/sync/singleflight version v0.10.0
What I have checked so far:
If I remove Souin, Mercure topic subscription works correctly.
The error occurs in singleflight, which is used in SouinBaseHandler.Upstream(), but the stack trace also includes mercure.(*responseController).flush().
The issue disappears when caching with Souin is disabled.

Questions:
Could Souin be affecting Mercure, causing this error?
Does Souin use any singleflight features that might conflict with Mercure’s subscriber handling?
Is there a way to work around this issue, such as adjusting Souin settings?
I’d appreciate any insights! Thanks in advance

Dockerfile

# Set environment variables for PIE
ENV CGO_ENABLED=1 XCADDY_SETCAP=1
ENV XCADDY_GO_BUILD_FLAGS="-ldflags \"-w -s -extldflags '-Wl,-z,stack-size=0x80000'\""
ENV CGO_CFLAGS="-fPIC" \
    CGO_LDFLAGS="-pie" \
    GOFLAGS="-buildmode=pie"
RUN xcaddy build \
	--output /usr/local/bin/frankenphp \
	--with github.com/dunglas/frankenphp=./ \
	--with github.com/dunglas/frankenphp/caddy=./caddy/ \
	# Mercure and Vulcain are included in the official build, but feel free to remove them
	--with github.com/dunglas/caddy-cbrotli \
	--with github.com/dunglas/mercure/caddy \
	--with github.com/dunglas/vulcain/caddy \
	# Add extra Caddy modules here
	--with github.com/darkweak/souin/plugins/caddy@fa61769ccc4499e8c72d994cd1b866d80bca3f7f \
	--with github.com/darkweak/souin@fa61769ccc4499e8c72d994cd1b866d80bca3f7f

trace

 | panic: feature not supported
php-1        | 
php-1        | runtime/debug.Stack()
php-1        |  /root/go/pkg/mod/golang.org/[email protected]/src/runtime/debug/stack.go:24 +0x5e
php-1        | golang.org/x/sync/singleflight.newPanicError({0x564a52ee4d60, 0xc0002dfc20})
php-1        |  /root/go/pkg/mod/golang.org/x/[email protected]/singleflight/singleflight.go:44 +0x25
php-1        | golang.org/x/sync/singleflight.(*Group).doCall.func2.1()
php-1        |  /root/go/pkg/mod/golang.org/x/[email protected]/singleflight/singleflight.go:193 +0x34
php-1        | panic({0x564a52ee4d60?, 0xc0002dfc20?})
php-1        |  /root/go/pkg/mod/golang.org/[email protected]/src/runtime/panic.go:770 +0x132
php-1        | github.com/dunglas/mercure.(*responseController).flush(0xc0008609c0)
php-1        |  /root/go/pkg/mod/github.com/dunglas/[email protected]/subscribe.go:63 +0x28b
php-1        | github.com/dunglas/mercure.(*Hub).registerSubscriber(0xc00094b7a0, {0x7fd7306aa380, 0xc0002f8ec0}, 0xc000cf2d80)
php-1        |  /root/go/pkg/mod/github.com/dunglas/[email protected]/subscribe.go:202 +0x59b
php-1        | github.com/dunglas/mercure.(*Hub).SubscribeHandler(0xc00094b7a0, {0x7fd7306aa380?, 0xc0002f8ec0?}, 0xc000cf2d80)
php-1        |  /root/go/pkg/mod/github.com/dunglas/[email protected]/subscribe.go:98 +0x59
php-1        | net/http.HandlerFunc.ServeHTTP(0xc000cf2c60?, {0x7fd7306aa380?, 0xc0002f8ec0?}, 0x564a5310c920?)
php-1        |  /root/go/pkg/mod/golang.org/[email protected]/src/net/http/server.go:2171 +0x29
php-1        | github.com/gorilla/mux.(*Router).ServeHTTP(0xc0008dec00, {0x7fd7306aa380, 0xc0002f8ec0}, 0xc000ce9320)
php-1        |  /root/go/pkg/mod/github.com/gorilla/[email protected]/mux.go:212 +0x1e2
php-1        | github.com/dunglas/mercure.(*Hub).initHandler.(*Secure).Handler.func2({0x7fd7306aa380, 0xc0002f8ec0}, 0xc0004e9901?)
php-1        |  /root/go/pkg/mod/github.com/unrolled/[email protected]/secure.go:213 +0x8d
php-1        | net/http.HandlerFunc.ServeHTTP(0x30?, {0x7fd7306aa380?, 0xc0002f8ec0?}, 0xc000bdc008?)
php-1        |  /root/go/pkg/mod/golang.org/[email protected]/src/net/http/server.go:2171 +0x29
php-1        | github.com/dunglas/mercure.(*Hub).ServeHTTP(...)
php-1        |  /root/go/pkg/mod/github.com/dunglas/[email protected]/handler.go:75
php-1        | github.com/dunglas/mercure/caddy.Mercure.ServeHTTP({0x1, 0x1, 0x1, 0x0, 0x0, 0x0, 0x0, {{0xc000428ec0, 0x22}, {0xc00079b780, ...}}, ...}, ...)
php-1        |  /root/go/pkg/mod/github.com/dunglas/mercure/[email protected]/mercure.go:319 +0xec
php-1        | github.com/caddyserver/caddy/v2/modules/caddyhttp.(*metricsInstrumentedHandler).ServeHTTP(0xc000958270, {0x564a531e6360, 0xc000999c70}, 0xc000ce9320, {0x564a531d33a0, 0xc0002df880})
php-1        |  /root/go/pkg/mod/github.com/caddyserver/caddy/[email protected]/modules/caddyhttp/metrics.go:157 +0x6be
php-1        | github.com/caddyserver/caddy/v2/modules/caddyhttp.wrapMiddleware.func1.1({0x564a531e6360, 0xc000999c70}, 0xc000ce9320)
php-1        |  /root/go/pkg/mod/github.com/caddyserver/caddy/[email protected]/modules/caddyhttp/routes.go:331 +0xd2
php-1        | github.com/caddyserver/caddy/v2/modules/caddyhttp.HandlerFunc.ServeHTTP(0xc000381350?, {0x564a531e6360?, 0xc000999c70?}, 0x2?)
php-1        |  /root/go/pkg/mod/github.com/caddyserver/caddy/[email protected]/modules/caddyhttp/caddyhttp.go:74 +0x29
php-1        | github.com/caddyserver/caddy/v2/modules/caddyhttp/encode.(*Encode).ServeHTTP(0xc000349e00, {0x7fd7306aa380, 0xc0002f8d40}, 0xc000ce9320, {0x564a531d33a0, 0xc0003817d0})
php-1        |  /root/go/pkg/mod/github.com/caddyserver/caddy/[email protected]/modules/caddyhttp/encode/encode.go:179 +0x572
php-1        | github.com/caddyserver/caddy/v2/modules/caddyhttp.(*metricsInstrumentedHandler).ServeHTTP(0xc000958210, {0x564a531e6570, 0xc0002f8c00}, 0xc000ce9320, {0x564a531d33a0, 0xc0003817d0})
php-1        |  /root/go/pkg/mod/github.com/caddyserver/caddy/[email protected]/modules/caddyhttp/metrics.go:157 +0x6be
php-1        | github.com/caddyserver/caddy/v2/modules/caddyhttp.wrapMiddleware.func1.1({0x564a531e6570, 0xc0002f8c00}, 0xc000ce9320)
php-1        |  /root/go/pkg/mod/github.com/caddyserver/caddy/[email protected]/modules/caddyhttp/routes.go:331 +0xd2
php-1        | github.com/caddyserver/caddy/v2/modules/caddyhttp.HandlerFunc.ServeHTTP(0x10?, {0x564a531e6570?, 0xc0002f8c00?}, 0x5c2408?)
php-1        |  /root/go/pkg/mod/github.com/caddyserver/caddy/[email protected]/modules/caddyhttp/caddyhttp.go:74 +0x29
php-1        | github.com/darkweak/souin/plugins/caddy.(*SouinCaddyMiddleware).ServeHTTP.func1({0x564a531e6570?, 0xc0002f8c00?}, 0xc000981990?)
php-1        |  /root/go/pkg/mod/github.com/darkweak/souin/plugins/[email protected]/httpcache.go:86 +0x33
php-1        | github.com/darkweak/souin/pkg/middleware.(*SouinBaseHandler).Upstream.func2()
php-1        |  /root/go/pkg/mod/github.com/darkweak/[email protected]/pkg/middleware/middleware.go:417 +0xaf
php-1        | golang.org/x/sync/singleflight.(*Group).doCall.func2(0xc000cedc56, 0xc000999c20, 0xc000bdc001?)
php-1        |  /root/go/pkg/mod/golang.org/x/[email protected]/singleflight/singleflight.go:198 +0x64
php-1        | golang.org/x/sync/singleflight.(*Group).doCall(0x564a52ec13e0?, 0xc000381f20?, {0xc00033c480?, 0x32?}, 0xc0004e98e0?)
php-1        |  /root/go/pkg/mod/golang.org/x/[email protected]/singleflight/singleflight.go:200 +0x96
php-1        | golang.org/x/sync/singleflight.(*Group).Do(0xc0007ba5c8, {0xc00033c480, 0x32}, 0xc00075b688)
php-1        |  /root/go/pkg/mod/golang.org/x/[email protected]/singleflight/singleflight.go:113 +0x15a
php-1        | github.com/darkweak/souin/pkg/middleware.(*SouinBaseHandler).Upstream(0xc0007ba480, 0xc0002f8c00, 0xc000cf26c0, 0xc0002df640, 0xc000381d10, {0xc00033c480, 0x32}, {0xc00051c9f4, 0x14})
php-1        |  /root/go/pkg/mod/github.com/darkweak/[email protected]/pkg/middleware/middleware.go:416 +0x2e7
php-1        | github.com/darkweak/souin/pkg/middleware.(*SouinBaseHandler).ServeHTTP.func4(0xc000cf26c0, 0xc0002f8c00)
php-1        |  /root/go/pkg/mod/github.com/darkweak/[email protected]/pkg/middleware/middleware.go:793 +0x115
php-1        | created by github.com/darkweak/souin/pkg/middleware.(*SouinBaseHandler).ServeHTTP in goroutine 118
php-1        |  /root/go/pkg/mod/github.com/darkweak/[email protected]/pkg/middleware/middleware.go:791 +0x1405
php-1        |  [recovered]

Image

@darkweak
Copy link
Owner

Hello @g-ra you're using an old commit of Souin fa61769ccc4499e8c72d994cd1b866d80bca3f7f, I think upgrading to at least v1.7.5 would be enough. By the way you'll have to use a storage from https://github.com/darkweak/storages.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

2 participants