Coder Social home page Coder Social logo

Comments (20)

darkweak avatar darkweak commented on May 20, 2024 1

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

from cache-handler.

darkweak avatar darkweak commented on May 20, 2024 1

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?

from cache-handler.

darkweak avatar darkweak commented on May 20, 2024 1

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.

from cache-handler.

francislavoie avatar francislavoie commented on May 20, 2024 1

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

from cache-handler.

darkweak avatar darkweak commented on May 20, 2024 1

The release is currently running 🤞

from cache-handler.

darkweak avatar darkweak commented on May 20, 2024 1

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

from cache-handler.

AlyoshaVasilieva avatar AlyoshaVasilieva commented on May 20, 2024 1

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!

from cache-handler.

darkweak avatar darkweak commented on May 20, 2024 1

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.

from cache-handler.

darkweak avatar darkweak commented on May 20, 2024 1

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

from cache-handler.

AlyoshaVasilieva avatar AlyoshaVasilieva commented on May 20, 2024 1

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

from cache-handler.

AlyoshaVasilieva avatar AlyoshaVasilieva commented on May 20, 2024

Yes, no issues waiting.

from cache-handler.

darkweak avatar darkweak commented on May 20, 2024

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).

from cache-handler.

AlyoshaVasilieva avatar AlyoshaVasilieva commented on May 20, 2024

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

from cache-handler.

mholt avatar mholt commented on May 20, 2024

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

from cache-handler.

darkweak avatar darkweak commented on May 20, 2024

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.

from cache-handler.

darkweak avatar darkweak commented on May 20, 2024

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

from cache-handler.

AlyoshaVasilieva avatar AlyoshaVasilieva commented on May 20, 2024
$ 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

from cache-handler.

darkweak avatar darkweak commented on May 20, 2024

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

from cache-handler.

darkweak avatar darkweak commented on May 20, 2024

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.

from cache-handler.

darkweak avatar darkweak commented on May 20, 2024

Thanks for your patience and your time for testing that!

from cache-handler.

Related Issues (20)

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    🖖 Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. 📊📈🎉

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google ❤️ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.