Skip to content

Commit

Permalink
gin: do not use gin context after returning response (#3398)
Browse files Browse the repository at this point in the history
  • Loading branch information
blotus authored Jan 10, 2025
1 parent 34c0e6a commit 303ce8e
Showing 1 changed file with 2 additions and 3 deletions.
5 changes: 2 additions & 3 deletions pkg/apiserver/controllers/v1/decisions.go
Original file line number Diff line number Diff line change
Expand Up @@ -394,8 +394,6 @@ func (c *Controller) StreamDecisionNonChunked(gctx *gin.Context, bouncerInfo *en
func (c *Controller) StreamDecision(gctx *gin.Context) {
var err error

ctx := gctx.Request.Context()

streamStartTime := time.Now().UTC()

bouncerInfo, err := getBouncerFromContext(gctx)
Expand Down Expand Up @@ -426,7 +424,8 @@ func (c *Controller) StreamDecision(gctx *gin.Context) {

if err == nil {
// Only update the last pull time if no error occurred when sending the decisions to avoid missing decisions
if err := c.DBClient.UpdateBouncerLastPull(ctx, streamStartTime, bouncerInfo.ID); err != nil {
// Do not reuse the context provided by gin because we already have sent the response to the client, so there's a chance for it to already be canceled
if err := c.DBClient.UpdateBouncerLastPull(context.Background(), streamStartTime, bouncerInfo.ID); err != nil {
log.Errorf("unable to update bouncer '%s' pull: %v", bouncerInfo.Name, err)
}
}
Expand Down

0 comments on commit 303ce8e

Please sign in to comment.