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

Panic if abort directive is used #44

Closed
AlyoshaVasilieva opened this issue Feb 13, 2023 · 20 comments · Fixed by #47
Closed

Panic if abort directive is used #44

AlyoshaVasilieva opened this issue Feb 13, 2023 · 20 comments · Fixed by #47
Assignees
Labels
bug Something isn't working

Comments

@AlyoshaVasilieva
Copy link

/etc/caddy/Caddyfile:

{
        order cache before rewrite
        cache
}

:80 {
        cache
        abort
}

Start caddy, then do curl http://127.0.0.1. Result: Caddy dies.

Feb 13 12:40:18 desrv systemd[1]: Started Caddy.
Feb 13 12:40:18 desrv caddy[4509]: {"level":"info","ts":1676320818.3576553,"logger":"tls.cache.maintenance","msg":"started background certificate maintenance","cache":"0xc00057b5e0"}
Feb 13 12:40:18 desrv caddy[4509]: {"level":"info","ts":1676320818.3577983,"logger":"tls","msg":"cleaning storage unit","description":"FileStorage:/var/lib/caddy/.local/share/caddy"}
Feb 13 12:40:18 desrv caddy[4509]: {"level":"info","ts":1676320818.3579395,"logger":"tls","msg":"finished cleaning storage units"}
Feb 13 12:40:18 desrv caddy[4509]: {"level":"info","ts":1676320818.3581178,"msg":"serving initial configuration"}
Feb 13 12:40:43 desrv caddy[4509]: panic: net/http: abort Handler
Feb 13 12:40:43 desrv caddy[4509]: goroutine 50 [running]:
Feb 13 12:40:43 desrv caddy[4509]: github.com/caddyserver/caddy/v2/modules/caddyhttp.StaticResponse.ServeHTTP({{0x0, 0x0}, 0x0, {0x0, 0x0}, 0x0, 0x1}, {0x24f43a0?, 0xc0001f6780?}, 0xc0000b8300, ...)
Feb 13 12:40:43 desrv caddy[4509]:         github.com/caddyserver/caddy/v2@v2.6.3/modules/caddyhttp/staticresp.go:184 +0xa38
Feb 13 12:40:43 desrv caddy[4509]: github.com/caddyserver/caddy/v2/modules/caddyhttp.wrapMiddleware.func1.1({0x24f43a0?, 0xc0001f6780?}, 0xc0006f0070?)
Feb 13 12:40:43 desrv caddy[4509]:         github.com/caddyserver/caddy/v2@v2.6.3/modules/caddyhttp/routes.go:290 +0x42
Feb 13 12:40:43 desrv caddy[4509]: github.com/caddyserver/caddy/v2/modules/caddyhttp.HandlerFunc.ServeHTTP(0x4487b9?, {0x24f43a0?, 0xc0001f6780?}, 0xffffffffffffffff?)
Feb 13 12:40:43 desrv caddy[4509]:         github.com/caddyserver/caddy/v2@v2.6.3/modules/caddyhttp/caddyhttp.go:58 +0x2f
Feb 13 12:40:43 desrv caddy[4509]: github.com/caddyserver/cache-handler.(*SouinCaddyPlugin).ServeHTTP.func1({0x0?, 0x185f960?}, 0xc0006f0070?)
Feb 13 12:40:43 desrv caddy[4509]:         github.com/caddyserver/cache-handler@v0.4.0/httpcache.go:129 +0x62
Feb 13 12:40:43 desrv caddy[4509]: github.com/darkweak/souin/plugins.DefaultSouinPluginCallback.func2({0x24f43a0?, 0xc0001f6780?}, 0xf?)
Feb 13 12:40:43 desrv caddy[4509]:         github.com/darkweak/souin@v1.6.27/plugins/base.go:210 +0x7a
Feb 13 12:40:43 desrv caddy[4509]: created by github.com/darkweak/souin/plugins.DefaultSouinPluginCallback
Feb 13 12:40:43 desrv caddy[4509]:         github.com/darkweak/souin@v1.6.27/plugins/base.go:206 +0x81b
Feb 13 12:40:43 desrv systemd[1]: caddy.service: Main process exited, code=exited, status=2/INVALIDARGUMENT
Feb 13 12:40:43 desrv systemd[1]: caddy.service: Failed with result 'exit-code'.
$ /usr/bin/caddy version
v2.6.3 h1:QRVBNIqfpqZ1eJacY44I6eUC1OcxQ8D04EKImzpj7S8=

Built about 15 minutes ago with xcaddy build --with github.com/caddyserver/cache-handler

This is a minimal repro. I have a service that only approved IPs are able to access, otherwise Caddy aborts the request, and when I hit it from an unapproved IP after adding caching it killed Caddy.

@darkweak
Copy link
Collaborator

Hello @AlyoshaVasilieva thanks for this report, I'll try to fix that. Thank you for the minimal reproductible example.

@darkweak darkweak added the bug Something isn't working label Feb 14, 2023
@darkweak darkweak self-assigned this Feb 14, 2023
@darkweak
Copy link
Collaborator

It seems the next minor version I'm working on patch that behavior and prevent the panic (darkweak/souin@master...feat/chore/refactoring-to-middleware-philosophy) and I plan to release that on the next week. Can you wait for that?

@AlyoshaVasilieva
Copy link
Author

Yes, no issues waiting.

@darkweak
Copy link
Collaborator

Hello @AlyoshaVasilieva, you can test the new version using xcaddy build --with github.com/darkweak/souin/plugins/caddy@ bbb3ba92593cfad8fa9d1bf6ec69e992b960dd52 --with github.com/darkweak/souin@ bbb3ba92593cfad8fa9d1bf6ec69e992b960dd52 (that's the beta before the tagged one, I need some feedbacks about that to ensure everything works).

@AlyoshaVasilieva
Copy link
Author

I can't build it.

$ xcaddy build --with github.com/darkweak/souin/plugins/caddy@ bbb3ba92593cfad8fa9d1bf6ec69e992b960dd52 --with github.com/darkweak/souin@ bbb3ba92593cfad8fa9d1bf6ec69e992b960dd52
2023/02/28 11:19:55 [ERROR] missing flag; caddy version already set at bbb3ba92593cfad8fa9d1bf6ec69e992b960dd52

without spaces after @:

$ xcaddy build --with github.com/darkweak/souin/plugins/caddy@bbb3ba92593cfad8fa9d1bf6ec69e992b960dd52 --with github.com/darkweak/souin@bbb3ba92593cfad8fa9d1bf6ec69e992b960dd52
2023/02/28 11:20:13 [INFO] Temporary folder: /tmp/buildenv_2023-02-28-1120.827881285
2023/02/28 11:20:13 [INFO] Writing main module: /tmp/buildenv_2023-02-28-1120.827881285/main.go
package main

import (
        caddycmd "github.com/caddyserver/caddy/v2/cmd"

        // plug in Caddy modules here
        _ "github.com/caddyserver/caddy/v2/modules/standard"
        _ "github.com/darkweak/souin/plugins/caddy"
        _ "github.com/darkweak/souin"
)

func main() {
        caddycmd.Main()
}
2023/02/28 11:20:13 [INFO] Initializing Go module
2023/02/28 11:20:13 [INFO] exec (timeout=10s): /usr/local/go/bin/go mod init caddy
go: creating new go.mod: module caddy
go: to add module requirements and sums:
        go mod tidy
2023/02/28 11:20:13 [INFO] Pinning versions
2023/02/28 11:20:13 [INFO] exec (timeout=0s): /usr/local/go/bin/go get -d -v github.com/caddyserver/caddy/v2
go: added github.com/beorn7/perks v1.0.1
go: added github.com/caddyserver/caddy/v2 v2.6.4
go: added github.com/caddyserver/certmagic v0.17.2
go: added github.com/cespare/xxhash/v2 v2.1.2
go: added github.com/go-task/slim-sprig v0.0.0-20210107165309-348f09dbbbc0
go: added github.com/golang/mock v1.6.0
go: added github.com/golang/protobuf v1.5.2
go: added github.com/google/pprof v0.0.0-20210407192527-94a9f03dee38
go: added github.com/google/uuid v1.3.0
go: added github.com/klauspost/cpuid/v2 v2.2.3
go: added github.com/libdns/libdns v0.2.1
go: added github.com/matttproud/golang_protobuf_extensions v1.0.1
go: added github.com/mholt/acmez v1.1.0
go: added github.com/miekg/dns v1.1.50
go: added github.com/onsi/ginkgo/v2 v2.2.0
go: added github.com/prometheus/client_golang v1.14.0
go: added github.com/prometheus/client_model v0.3.0
go: added github.com/prometheus/common v0.37.0
go: added github.com/prometheus/procfs v0.8.0
go: added github.com/quic-go/qpack v0.4.0
go: added github.com/quic-go/qtls-go1-18 v0.2.0
go: added github.com/quic-go/qtls-go1-19 v0.2.0
go: added github.com/quic-go/qtls-go1-20 v0.1.0
go: added github.com/quic-go/quic-go v0.32.0
go: added go.uber.org/atomic v1.9.0
go: added go.uber.org/multierr v1.6.0
go: added go.uber.org/zap v1.24.0
go: added golang.org/x/crypto v0.5.0
go: added golang.org/x/exp v0.0.0-20221205204356-47842c84f3db
go: added golang.org/x/mod v0.6.0
go: added golang.org/x/net v0.7.0
go: added golang.org/x/sys v0.5.0
go: added golang.org/x/term v0.5.0
go: added golang.org/x/text v0.7.0
go: added golang.org/x/tools v0.2.0
go: added google.golang.org/protobuf v1.28.1
2023/02/28 11:20:14 [INFO] exec (timeout=0s): /usr/local/go/bin/go get -d -v github.com/darkweak/souin/plugins/caddy@bbb3ba92593cfad8fa9d1bf6ec69e992b960dd52 github.com/caddyserver/caddy/v2
go: downloading github.com/darkweak/souin v1.6.29
github.com/darkweak/souin/plugins/caddy imports
        github.com/darkweak/souin/configurationtypes: reading github.com/darkweak/souin/go.mod at revision v1.6.29: unknown revision v1.6.29
github.com/darkweak/souin/plugins/caddy imports
        github.com/darkweak/souin/pkg/middleware: reading github.com/darkweak/souin/go.mod at revision v1.6.29: unknown revision v1.6.29
github.com/darkweak/souin/plugins/caddy imports
        github.com/darkweak/souin/pkg/storage: reading github.com/darkweak/souin/go.mod at revision v1.6.29: unknown revision v1.6.29
github.com/darkweak/souin/plugins/caddy imports
        github.com/darkweak/souin/pkg/surrogate/providers: reading github.com/darkweak/souin/go.mod at revision v1.6.29: unknown revision v1.6.29
2023/02/28 11:20:17 [FATAL] exit status 1

@mholt
Copy link
Member

mholt commented Feb 28, 2023

@AlyoshaVasilieva I think it's because you have spaces between @ and the version.

@darkweak
Copy link
Collaborator

Oh my bad, I'll push a new commit without the bump. The v1.6.29 doesn't exist yet because it's not a tagged version.

@darkweak
Copy link
Collaborator

darkweak commented Feb 28, 2023

Can you try with this commit instead? 62fb37ab00335b3c1576909388c3cd61081ad647

xcaddy build --with github.com/darkweak/souin@62fb37ab00335b3c1576909388c3cd61081ad647 --with github.com/darkweak/souin/plugins/caddy@62fb37ab00335b3c1576909388c3cd61081ad647

The dependency github.com/darkweak/souin must be placed before the github.com/darkweak/souin/plugins/caddy

@AlyoshaVasilieva
Copy link
Author

$ xcaddy build --with github.com/darkweak/souin@62fb37ab00335b3c1576909388c3cd61081ad647 --with github.com/darkweak/souin/plugins/caddy@62fb37ab00335b3c1576909388c3cd61081ad647
2023/02/28 11:58:49 [INFO] Temporary folder: /tmp/buildenv_2023-02-28-1158.4246201301
2023/02/28 11:58:49 [INFO] Writing main module: /tmp/buildenv_2023-02-28-1158.4246201301/main.go
package main

import (
        caddycmd "github.com/caddyserver/caddy/v2/cmd"

        // plug in Caddy modules here
        _ "github.com/caddyserver/caddy/v2/modules/standard"
        _ "github.com/darkweak/souin"
        _ "github.com/darkweak/souin/plugins/caddy"
)

func main() {
        caddycmd.Main()
}
2023/02/28 11:58:49 [INFO] Initializing Go module
2023/02/28 11:58:49 [INFO] exec (timeout=10s): /usr/local/go/bin/go mod init caddy
go: creating new go.mod: module caddy
go: to add module requirements and sums:
        go mod tidy
2023/02/28 11:58:49 [INFO] Pinning versions
2023/02/28 11:58:49 [INFO] exec (timeout=0s): /usr/local/go/bin/go get -d -v github.com/caddyserver/caddy/v2
go: added github.com/beorn7/perks v1.0.1
go: added github.com/caddyserver/caddy/v2 v2.6.4
go: added github.com/caddyserver/certmagic v0.17.2
go: added github.com/cespare/xxhash/v2 v2.1.2
go: added github.com/go-task/slim-sprig v0.0.0-20210107165309-348f09dbbbc0
go: added github.com/golang/mock v1.6.0
go: added github.com/golang/protobuf v1.5.2
go: added github.com/google/pprof v0.0.0-20210407192527-94a9f03dee38
go: added github.com/google/uuid v1.3.0
go: added github.com/klauspost/cpuid/v2 v2.2.3
go: added github.com/libdns/libdns v0.2.1
go: added github.com/matttproud/golang_protobuf_extensions v1.0.1
go: added github.com/mholt/acmez v1.1.0
go: added github.com/miekg/dns v1.1.50
go: added github.com/onsi/ginkgo/v2 v2.2.0
go: added github.com/prometheus/client_golang v1.14.0
go: added github.com/prometheus/client_model v0.3.0
go: added github.com/prometheus/common v0.37.0
go: added github.com/prometheus/procfs v0.8.0
go: added github.com/quic-go/qpack v0.4.0
go: added github.com/quic-go/qtls-go1-18 v0.2.0
go: added github.com/quic-go/qtls-go1-19 v0.2.0
go: added github.com/quic-go/qtls-go1-20 v0.1.0
go: added github.com/quic-go/quic-go v0.32.0
go: added go.uber.org/atomic v1.9.0
go: added go.uber.org/multierr v1.6.0
go: added go.uber.org/zap v1.24.0
go: added golang.org/x/crypto v0.5.0
go: added golang.org/x/exp v0.0.0-20221205204356-47842c84f3db
go: added golang.org/x/mod v0.6.0
go: added golang.org/x/net v0.7.0
go: added golang.org/x/sys v0.5.0
go: added golang.org/x/term v0.5.0
go: added golang.org/x/text v0.7.0
go: added golang.org/x/tools v0.2.0
go: added google.golang.org/protobuf v1.28.1
2023/02/28 11:58:49 [INFO] exec (timeout=0s): /usr/local/go/bin/go get -d -v github.com/darkweak/souin@62fb37ab00335b3c1576909388c3cd61081ad647 github.com/caddyserver/caddy/v2
go: upgraded github.com/cespare/xxhash/v2 v2.1.2 => v2.2.0
go: added github.com/darkweak/souin v1.6.29-0.20230228195014-62fb37ab0033
go: upgraded github.com/google/pprof v0.0.0-20210407192527-94a9f03dee38 => v0.0.0-20210720184732-4bb14d4b1be1
go: upgraded github.com/matttproud/golang_protobuf_extensions v1.0.1 => v1.0.4
go: upgraded github.com/miekg/dns v1.1.50 => v1.1.51
go: upgraded github.com/prometheus/common v0.37.0 => v0.40.0
go: upgraded github.com/prometheus/procfs v0.8.0 => v0.9.0
go: upgraded golang.org/x/mod v0.6.0 => v0.8.0
go: upgraded golang.org/x/tools v0.2.0 => v0.6.0
2023/02/28 11:58:50 [INFO] exec (timeout=0s): /usr/local/go/bin/go get -d -v github.com/darkweak/souin/plugins/caddy@62fb37ab00335b3c1576909388c3cd61081ad647 github.com/caddyserver/caddy/v2
go: added github.com/darkweak/souin/plugins/caddy v0.0.0-20230228195014-62fb37ab0033
go: upgraded go.uber.org/atomic v1.9.0 => v1.10.0
go: upgraded go.uber.org/multierr v1.6.0 => v1.9.0
2023/02/28 11:58:51 [INFO] exec (timeout=0s): /usr/local/go/bin/go get -d -v
caddy imports
        github.com/darkweak/souin/plugins/caddy imports
        github.com/darkweak/souin/api: cannot find module providing package github.com/darkweak/souin/api
caddy imports
        github.com/darkweak/souin/plugins/caddy imports
        github.com/darkweak/souin/plugins: cannot find module providing package github.com/darkweak/souin/plugins
caddy imports
        github.com/darkweak/souin/plugins/caddy imports
        github.com/darkweak/souin/rfc: cannot find module providing package github.com/darkweak/souin/rfc
2023/02/28 11:58:53 [FATAL] exit status 1

@darkweak
Copy link
Collaborator

I'm trying to reproduce your issue on another laptop.

@darkweak
Copy link
Collaborator

I think xcaddy doesn't fetch packages respecting the replace directive. I think you'll have to fetch the repository, go to the feat/chore/refactoring-to-middleware-philosophy branch and run the xcaddy build in the souin/plugins/caddy directory.

git clone https://github.com/darkweak/souin
cd souin
git checkout feat/chore/refactoring-to-middleware-philosophy
cd plugins/caddy
xcaddy build --with github.com/darkweak/souin/plugins/caddy=./ --with github.com/darkweak/souin=../..

I'll try to release that asap to avoid these build constaints.

@francislavoie
Copy link
Member

Correct - but more specifically, go get does not respect replace.

@darkweak
Copy link
Collaborator

darkweak commented Mar 1, 2023

The release is currently running 🤞

@darkweak
Copy link
Collaborator

darkweak commented Mar 1, 2023

It's now available using xcaddy build --with github.com/darkweak/souin/plugins/caddy

@AlyoshaVasilieva
Copy link
Author

It no longer panics! However, when trying to use redis requests hang forever.

{
        order cache before rewrite
        cache {
                timeout {
                        backend 2s
                        cache 30ms
                }
        }
}

:80 {
        cache {
                redis {
                        configuration {
                                Addr 127.0.0.1:6379
                                DialTimeout 2s
                                ReadTimeout 5s
                                WriteTimeout 5s
                                PoolTimeout 10s
                        }
                }
        }
        respond "Hello"
}

I've set all those timeouts in an attempt to make it timeout and issue an HTTP error, but it doesn't:

$ curl http://127.0.0.1:80 -v --max-time 60
*   Trying 127.0.0.1:80...
* Connected to 127.0.0.1 (127.0.0.1) port 80 (#0)
> GET / HTTP/1.1
> Host: 127.0.0.1
> User-Agent: curl/7.74.0
> Accept: */*
>
* Operation timed out after 60000 milliseconds with 0 bytes received
* Closing connection 0
curl: (28) Operation timed out after 60000 milliseconds with 0 bytes received

I'm not actually sure I've set it up correctly, but I'm not getting any error messages.

After attempting to enable logging*, this is all I see in the logs:

Mar 01 09:16:26 desrv systemd[1]: Starting Caddy...
Mar 01 09:16:26 desrv caddy[21809]: caddy.HomeDir=/var/lib/caddy
Mar 01 09:16:26 desrv caddy[21809]: caddy.AppDataDir=/var/lib/caddy/.local/share/caddy
Mar 01 09:16:26 desrv caddy[21809]: caddy.AppConfigDir=/var/lib/caddy/.config/caddy
Mar 01 09:16:26 desrv caddy[21809]: caddy.ConfigAutosavePath=/var/lib/caddy/.config/caddy/autosave.json
Mar 01 09:16:26 desrv caddy[21809]: caddy.Version=v2.6.4 h1:2hwYqiRwk1tf3VruhMpLcYTg+11fCdr8S3jhNAdnPy8=
Mar 01 09:16:26 desrv caddy[21809]: runtime.GOOS=linux
Mar 01 09:16:26 desrv caddy[21809]: runtime.GOARCH=amd64
Mar 01 09:16:26 desrv caddy[21809]: runtime.Compiler=gc
Mar 01 09:16:26 desrv caddy[21809]: runtime.NumCPU=1
Mar 01 09:16:26 desrv caddy[21809]: runtime.GOMAXPROCS=1
Mar 01 09:16:26 desrv caddy[21809]: runtime.Version=go1.20
Mar 01 09:16:26 desrv caddy[21809]: os.Getwd=/
Mar 01 09:16:26 desrv caddy[21809]: LANG=en_US.UTF-8
Mar 01 09:16:26 desrv caddy[21809]: PATH=/usr/local/sbin:/usr/local/bin:/usr/sbin:/usr/bin:/sbin:/bin:/snap/bin
Mar 01 09:16:26 desrv caddy[21809]: NOTIFY_SOCKET=/run/systemd/notify
Mar 01 09:16:26 desrv caddy[21809]: HOME=/var/lib/caddy
Mar 01 09:16:26 desrv caddy[21809]: LOGNAME=caddy
Mar 01 09:16:26 desrv caddy[21809]: USER=caddy
Mar 01 09:16:26 desrv caddy[21809]: INVOCATION_ID=69251e0770554977adcd78ca4994c93f
Mar 01 09:16:26 desrv caddy[21809]: JOURNAL_STREAM=8:365012
Mar 01 09:16:26 desrv caddy[21809]: {"level":"info","ts":1677690986.5054333,"msg":"using provided configuration","config_file":"/etc/caddy/Caddyfile","config_adapter":""}
Mar 01 09:16:26 desrv caddy[21809]: 2023/03/01 17:16:26.509        INFO        admin        admin endpoint started        {"address": "localhost:2019", "enforce_origin": false, "origins": ["//localhost:2019", "//[::1]:2019", "//127.0.0.1:2019"]}
Mar 01 09:16:26 desrv caddy[21809]: 2023/03/01 17:16:26.509        WARN        http        server is listening only on the HTTP port, so no automatic HTTPS will be applied to this server        {"server_name": "srv0", "http_port": 80}
Mar 01 09:16:26 desrv caddy[21809]: 2023/03/01 17:16:26.510        DEBUG        http.handlers.cache        Storer initialized.
Mar 01 09:16:26 desrv caddy[21809]: 2023/03/01 17:16:26.510        DEBUG        http.handlers.cache        Surrogate storage initialized.
Mar 01 09:16:26 desrv caddy[21809]: 2023/03/01 17:16:26.510        DEBUG        http.handlers.cache        Set Souin as Cache-Status name
Mar 01 09:16:26 desrv caddy[21809]: 2023/03/01 17:16:26.510        DEBUG        http.handlers.cache        Allow 2 method(s). [GET HEAD].
Mar 01 09:16:26 desrv caddy[21809]: 2023/03/01 17:16:26.510        INFO        http.handlers.cache        Set backend timeout to 2s
Mar 01 09:16:26 desrv caddy[21809]: 2023/03/01 17:16:26.510        INFO        http.handlers.cache        Set cache timeout to 2s
Mar 01 09:16:26 desrv caddy[21809]: 2023/03/01 17:16:26.510        INFO        http.handlers.cache        Souin configuration is now loaded.
Mar 01 09:16:26 desrv caddy[21809]: 2023/03/01 17:16:26.511        DEBUG        http        starting server loop        {"address": "[::]:80", "tls": false, "http3": false}
Mar 01 09:16:26 desrv caddy[21809]: 2023/03/01 17:16:26.511        INFO        http.log        server running        {"name": "srv0", "protocols": ["h1", "h2", "h3"]}
Mar 01 09:16:26 desrv caddy[21809]: 2023/03/01 17:16:26.511        INFO        autosaved config (load with --resume flag)        {"file": "/var/lib/caddy/.config/caddy/autosave.json"}
Mar 01 09:16:26 desrv systemd[1]: Started Caddy.
Mar 01 09:16:26 desrv caddy[21809]: 2023/03/01 17:16:26.514        INFO        serving initial configuration
Mar 01 09:16:26 desrv caddy[21809]: 2023/03/01 17:16:26.514        INFO        tls.cache.maintenance        started background certificate maintenance        {"cache": "0xc00056b880"}
Mar 01 09:16:26 desrv caddy[21809]: 2023/03/01 17:16:26.514        INFO        tls        cleaning storage unit        {"description": "FileStorage:/var/lib/caddy/.local/share/caddy"}
Mar 01 09:16:26 desrv caddy[21809]: 2023/03/01 17:16:26.514        INFO        tls        finished cleaning storage units

* caddyfile:

{
        debug
        log {
                level debug
                format console
                output stderr
        }
        order cache before rewrite
        cache {
                timeout {
                        backend 2s
                        cache 30ms
                }
        }
}

:80 {
        log {
                level debug
                format console
                output stderr
        }
        cache {
                redis {
                        configuration {
                                Addr 127.0.0.1:6379
                                DialTimeout 2s
                                ReadTimeout 5s
                                WriteTimeout 5s
                                PoolTimeout 10s
                        }
                }
        }
        respond "Hello"
}

Well, it's a different issue now, the original one seems solved. This is a huge improvement over panicking, so thank you!

@darkweak
Copy link
Collaborator

darkweak commented Mar 1, 2023

I'll have a look at that and try to fix this weird behavior. I will add some e2e test cases to ensure redis works well.

@darkweak
Copy link
Collaborator

darkweak commented Mar 2, 2023

I found the error, it comes from the Prefix function in the redis storage provider. I forgot to return an empty value if no stored keys are matching the expected one. I'm writing the fix with the environment test cases.

@darkweak
Copy link
Collaborator

darkweak commented Mar 2, 2023

@AlyoshaVasilieva Can you try with xcaddy build --with github.com/darkweak/souin@f05fcc6808b9ba8cc61833b329b0b2b4697a2ad7 --with github.com/darkweak/souin/plugins/caddy@f05fcc6808b9ba8cc61833b329b0b2b4697a2ad7?

@AlyoshaVasilieva
Copy link
Author

It appears to be working, I can't find any further issue. Thanks!

@darkweak
Copy link
Collaborator

darkweak commented Mar 2, 2023

Thanks for your patience and your time for testing that!

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
bug Something isn't working
Projects
None yet
Development

Successfully merging a pull request may close this issue.

4 participants