From fe861683259e603a599d601a5eb6b1f1749283ea Mon Sep 17 00:00:00 2001 From: Dylan Tinianov Date: Thu, 31 Oct 2024 11:05:48 -0400 Subject: [PATCH] Fix ctx cancel --- pkg/solana/client/multinode/transaction_sender.go | 14 ++++++++++++-- 1 file changed, 12 insertions(+), 2 deletions(-) diff --git a/pkg/solana/client/multinode/transaction_sender.go b/pkg/solana/client/multinode/transaction_sender.go index 324060757..259a78a9c 100644 --- a/pkg/solana/client/multinode/transaction_sender.go +++ b/pkg/solana/client/multinode/transaction_sender.go @@ -102,7 +102,13 @@ func (txSender *TransactionSender[TX, RESULT, CHAIN_ID, RPC]) SendTransaction(ct } txSenderCtx, cancel := txSender.chStop.NewCtx() - defer cancel() + reportWg := sync.WaitGroup{} + defer func() { + go func() { + reportWg.Wait() + cancel() + }() + }() healthyNodesNum := 0 err := txSender.multiNode.DoAll(txSenderCtx, func(ctx context.Context, rpc RPC, isSendOnly bool) { @@ -152,7 +158,11 @@ func (txSender *TransactionSender[TX, RESULT, CHAIN_ID, RPC]) SendTransaction(ct } txSender.wg.Add(1) - go txSender.reportSendTxAnomalies(tx, txResultsToReport) + reportWg.Add(1) + go func() { + txSender.reportSendTxAnomalies(tx, txResultsToReport) + reportWg.Done() + }() return txSender.collectTxResults(ctx, tx, healthyNodesNum, txResults, startTime) }