diff --git a/libp2p/protocols/secure/secure.nim b/libp2p/protocols/secure/secure.nim index aeff8fa50..ab92d9efe 100644 --- a/libp2p/protocols/secure/secure.nim +++ b/libp2p/protocols/secure/secure.nim @@ -79,7 +79,7 @@ method init*(s: Secure) {.gcsafe.} = except CancelledError as exc: warn "securing connection canceled" await conn.close() - raise + raise exc except CatchableError as exc: warn "securing connection failed", msg = exc.msg await conn.close() diff --git a/libp2p/stream/bufferstream.nim b/libp2p/stream/bufferstream.nim index 71562b861..6f0058070 100644 --- a/libp2p/stream/bufferstream.nim +++ b/libp2p/stream/bufferstream.nim @@ -306,6 +306,6 @@ method close*(s: BufferStream) {.async, gcsafe.} = else: trace "attempt to close an already closed bufferstream", trace = getStackTrace() except CancelledError as exc: - raise + raise exc except CatchableError as exc: trace "error closing buffer stream", exc = exc.msg diff --git a/libp2p/switch.nim b/libp2p/switch.nim index ce3943be1..32be1abdf 100644 --- a/libp2p/switch.nim +++ b/libp2p/switch.nim @@ -68,7 +68,7 @@ type streamHandler*: StreamHandler secureManagers*: seq[Secure] pubSub*: Option[PubSub] - dialLock: Table[string, AsyncLock] + dialLock: Table[PeerID, AsyncLock] hooks: Table[Lifecycle, HashSet[Hook]] pubsubMonitors: Table[PeerId, Future[void]] @@ -291,7 +291,7 @@ proc internalConnect(s: Switch, return conn - let lock = s.dialLock.mgetOrPut($peerId, newAsyncLock()) + let lock = s.dialLock.mgetOrPut(peerId, newAsyncLock()) try: await lock.acquire() @@ -315,7 +315,7 @@ proc internalConnect(s: Switch, libp2p_dialed_peers.inc() except CancelledError as exc: trace "dialing canceled", exc = exc.msg, peer = peerId - raise + raise exc except CatchableError as exc: trace "dialing failed", exc = exc.msg, peer = peerId libp2p_failed_dials.inc()