Skip to content

Conversation

@MicahParks
Copy link
Contributor

The keyfunc.NewDefault function will launch a new goroutine. This goroutine will periodically perform an HTTP request to refresh the remote JWK Set.

The current implementation calls this function every time a JWT's expiration is checked. This will cause a compounding resource leak of goroutines periodically performing HTTP requests. This PR aims to fix that.

@MicahParks MicahParks requested a review from davidcollom as a code owner June 1, 2025 00:23
var k keyfunc.Keyfunc
var err error
if opts.JWKSURI != "" {
k, err = keyfunc.NewDefaultCtx(context.TODO(), []string{opts.JWKSURI})
Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I used the same context as what was being replaced. The keyfunc.NewDefault function can be used instead if no context is required. The context.Background() will be used by default.

Copy link
Contributor

@davidcollom davidcollom left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Amazing! Thanks for raising! <3

@davidcollom davidcollom merged commit 07baf17 into jetstack:main Jun 3, 2025
7 checks passed
@github-actions github-actions bot mentioned this pull request Nov 13, 2025
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

Successfully merging this pull request may close these issues.

2 participants