Skip to content

Commit 496773d

Browse files
authored
Merge pull request #513 from crazy-max/notif-context-leak
notif: fix webhook timeout context cleanup
2 parents b0fc929 + 45599e8 commit 496773d

1 file changed

Lines changed: 2 additions & 3 deletions

File tree

internal/notif/webhook/client.go

Lines changed: 2 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -51,9 +51,8 @@ func (c *Client) Send(jnl journal.Journal) error {
5151
return err
5252
}
5353

54-
cancelCtx, cancel := context.WithCancelCause(context.Background())
55-
timeoutCtx, _ := context.WithTimeoutCause(cancelCtx, *c.cfg.Timeout, errors.WithStack(context.DeadlineExceeded)) //nolint:govet // no need to manually cancel this context as we already rely on parent
56-
defer func() { cancel(errors.WithStack(context.Canceled)) }()
54+
timeoutCtx, cancel := context.WithTimeoutCause(context.Background(), *c.cfg.Timeout, errors.WithStack(context.DeadlineExceeded))
55+
defer cancel()
5756

5857
hc := http.Client{}
5958
req, err := http.NewRequestWithContext(timeoutCtx, c.cfg.Method, c.cfg.Endpoint, bytes.NewBuffer(body))

0 commit comments

Comments
 (0)