couper
couper copied to clipboard
json sync leaks go-routine with `-watch` flag
Describe the bug
The SyncedJSON
new() method is missing the command context to shutdown the initialized goroutine on configuration-file changes. See https://github.com/avenga/couper/blob/master/json/synced_json.go#L53
To Reproduce Steps to reproduce the behavior:
- Which Couper version? Run
couper version
ordocker run avenga/couper version
edge 2022-08-24 add847c
go version go1.19 linux/amd64
- Provide your configuration file
*.hcl
. Remove sensitive data.
https://github.com/avenga/couper-oidc-gateway/blob/master/couper.hcl
- Provide a
curl
call for reproduction
- See an error response or error log.
- Provide valid oidc parameters, see https://github.com/avenga/couper-oidc-gateway/blob/master/README.md
- start with
couper run -f oidc-conf.hcl -watch -debug
. - browse to http://localhost:6060/debug/pprof/goroutine?debug=1 and have a look at the goroutine count for
json.(*SyncedJSON).sync
- do unrelated changes to the config to trigger a
-watch
related reload. - with every reload the goroutine count for
json.(*SyncedJSON).sync
will increase
Expected behavior goroutine shutdown on command cancel