From 1342b45b29d6f508d00972e14159068febea54c3 Mon Sep 17 00:00:00 2001 From: Diego Date: Wed, 20 Mar 2024 11:04:50 +0100 Subject: [PATCH] handle CancelledError --- libp2p/protocols/pubsub/pubsubpeer.nim | 5 ++++- 1 file changed, 4 insertions(+), 1 deletion(-) diff --git a/libp2p/protocols/pubsub/pubsubpeer.nim b/libp2p/protocols/pubsub/pubsubpeer.nim index 41ffc70fb..1eaa80f37 100644 --- a/libp2p/protocols/pubsub/pubsubpeer.nim +++ b/libp2p/protocols/pubsub/pubsubpeer.nim @@ -299,7 +299,10 @@ proc sendMsgSlow(p: PubSubPeer, msg: seq[byte]) {.async.} = return trace "sending encoded msg to peer", conn, encoded = shortLog(msg), p - await sendMsgContinue(conn, conn.writeLp(msg)) + try: + await sendMsgContinue(conn, conn.writeLp(msg)) + except CancelledError as exc: + trace "Continuation for pending `sendMsg` future has been unexpectedly cancelled" proc sendMsg(p: PubSubPeer, msg: seq[byte]): Future[void] = if p.sendConn != nil and not p.sendConn.closed():