-
Notifications
You must be signed in to change notification settings - Fork 55
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
Fixing context cancelled for webhook post calls #399
Conversation
Codecov Report
@@ Coverage Diff @@
## main #399 +/- ##
==========================================
- Coverage 20.43% 20.43% -0.01%
==========================================
Files 48 48
Lines 5422 5423 +1
==========================================
Hits 1108 1108
- Misses 4139 4140 +1
Partials 175 175
|
pkg/service/webhook/service.go
Outdated
@@ -191,9 +192,9 @@ func (s Service) PublishWebhook(ctx context.Context, noun Noun, verb Verb, paylo | |||
continue | |||
} | |||
|
|||
err = s.post(ctx, url, string(postJSONData)) | |||
err = s.post(context.Background(), url, string(postJSONData)) |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
context.Background
mean that this call can wait forever. This can lead to memory increasing without a bound.
Instead, I suggest to us some cancellable context.
return | ||
} | ||
ctx, cancel := context.WithTimeout(context.Background(), duration) | ||
defer cancel() | ||
err = s.post(ctx, url, string(postJSONData)) |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
can combine with the line below
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
This has changed locatoin
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Awesome! Couple of small nits.
Overview
Fixes an issue where we would get cancelled contexts for webhook calls