From 2ba2c51568264490fdcc9132608db679291005ad Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?=E4=B8=87=E7=8E=89=E5=8B=A4?= Date: Wed, 16 Oct 2024 21:06:13 +0800 Subject: [PATCH] fix:callback function execution start context being canceled --- producer/producer.go | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/producer/producer.go b/producer/producer.go index 00eb351d..2cbeff68 100644 --- a/producer/producer.go +++ b/producer/producer.go @@ -403,7 +403,7 @@ func (p *defaultProducer) sendAsync(ctx context.Context, msg *primitive.Message, ctx, cancel := context.WithTimeout(ctx, p.options.SendMsgTimeout) err := p.client.InvokeAsync(ctx, addr, p.buildSendRequest(mq, msg), func(command *remote.RemotingCommand, err error) { - cancel() + defer cancel() if err != nil { h(ctx, nil, err) return