Skip to content

Commit 3538144

Browse files
wanyuqin万玉勤
and
万玉勤
authored
fix:callback function execution start context being canceled (#1175)
Co-authored-by: 万玉勤 <[email protected]>
1 parent ac4e3d6 commit 3538144

File tree

1 file changed

+1
-1
lines changed

1 file changed

+1
-1
lines changed

producer/producer.go

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -403,7 +403,7 @@ func (p *defaultProducer) sendAsync(ctx context.Context, msg *primitive.Message,
403403

404404
ctx, cancel := context.WithTimeout(ctx, p.options.SendMsgTimeout)
405405
err := p.client.InvokeAsync(ctx, addr, p.buildSendRequest(mq, msg), func(command *remote.RemotingCommand, err error) {
406-
cancel()
406+
defer cancel()
407407
if err != nil {
408408
h(ctx, nil, err)
409409
return

0 commit comments

Comments
 (0)