diff --git a/libp2p/protocols/secure/secure.nim b/libp2p/protocols/secure/secure.nim index 3809ae0..5fcfeb9 100644 --- a/libp2p/protocols/secure/secure.nim +++ b/libp2p/protocols/secure/secure.nim @@ -81,7 +81,7 @@ proc handleConn*(s: Secure, let futs = @[conn.join(), sconn.join()] await futs[0] or futs[1] for f in futs: - if not f.finished: f.cancel # cancel outstanding join() + if not f.finished: await f.cancelAndWait() # cancel outstanding join() await allFuturesThrowing( sconn.close(), conn.close()) diff --git a/libp2p/transports/tcptransport.nim b/libp2p/transports/tcptransport.nim index 48f0e57..53b60e6 100644 --- a/libp2p/transports/tcptransport.nim +++ b/libp2p/transports/tcptransport.nim @@ -88,7 +88,7 @@ proc connHandler*(t: TcpTransport, let futs = @[client.join(), conn.join()] await futs[0] or futs[1] for f in futs: - if not f.finished: f.cancel # cancel outstanding join() + if not f.finished: await f.cancelAndWait() # cancel outstanding join() trace "Cleaning up client", addrs = $client.remoteAddress, conn