Skip to content

Commit

Permalink
avoid cancelling send future (#1075)
Browse files Browse the repository at this point in the history
  • Loading branch information
arnetheduck authored Mar 20, 2024
1 parent fdf53d1 commit 467b5b4
Showing 1 changed file with 3 additions and 1 deletion.
4 changes: 3 additions & 1 deletion libp2p/protocols/pubsub/pubsubpeer.nim
Original file line number Diff line number Diff line change
Expand Up @@ -431,7 +431,9 @@ proc sendNonPriorityTask(p: PubSubPeer) {.async.} =
# clearSendPriorityQueue ensures we're not waiting for an already-finished
# future
if p.rpcmessagequeue.sendPriorityQueue.len > 0:
await p.rpcmessagequeue.sendPriorityQueue[^1]
# `race` prevents `p.rpcmessagequeue.sendPriorityQueue[^1]` from being
# cancelled when this task is cancelled
discard await race(p.rpcmessagequeue.sendPriorityQueue[^1])
when defined(pubsubpeer_queue_metrics):
libp2p_gossipsub_non_priority_queue_size.dec(labelValues = [$p.peerId])
await p.sendMsg(msg)
Expand Down

0 comments on commit 467b5b4

Please sign in to comment.