fix: handle context correctly in processEvents (#7320)

This commit is contained in:
Livio Spring
2024-01-31 11:25:28 +01:00
committed by GitHub
parent 46bffd24ee
commit e000fdd792
2 changed files with 6 additions and 6 deletions

View File

@@ -471,11 +471,11 @@ func (h *Handler) processEvents(ctx context.Context, config *triggerConfig) (add
txCtx := ctx
if h.txDuration > 0 {
var cancel func()
ctx, cancel = context.WithTimeout(ctx, h.txDuration)
defer cancel()
var cancel, cancelTx func()
// add 100ms to store current state if iteration takes too long
txCtx, cancel = context.WithTimeout(ctx, h.txDuration+100*time.Millisecond)
txCtx, cancelTx = context.WithTimeout(ctx, h.txDuration+100*time.Millisecond)
defer cancelTx()
ctx, cancel = context.WithTimeout(ctx, h.txDuration)
defer cancel()
}