Merge branch 'master' into race-cancell

This commit is contained in:
diegomrsantos 2024-08-29 22:35:31 +02:00 committed by GitHub
commit 231b58142a
No known key found for this signature in database
GPG Key ID: B5690EEEBB952194
36 changed files with 132 additions and 122 deletions

View File

@ -8,7 +8,7 @@ on:
jobs: jobs:
test_amd64: test_amd64:
name: Daily amd64 name: Daily amd64
uses: ./.github/workflows/base_daily_tests.yml uses: ./.github/workflows/daily_common.yml
with: with:
nim: "[{'branch': 'version-1-6', 'memory_management': 'refc'}, {'branch': 'version-2-0', 'memory_management': 'refc'}]" nim: "[{'branch': 'version-1-6', 'memory_management': 'refc'}, {'branch': 'version-2-0', 'memory_management': 'refc'}]"
cpu: "['amd64']" cpu: "['amd64']"

View File

@ -8,7 +8,7 @@ on:
jobs: jobs:
test_nim_devel: test_nim_devel:
name: Daily Nim Devel name: Daily Nim Devel
uses: ./.github/workflows/base_daily_tests.yml uses: ./.github/workflows/daily_common.yml
with: with:
nim: "[{'branch': 'devel', 'memory_management': 'orc'}]" nim: "[{'branch': 'devel', 'memory_management': 'orc'}]"
cpu: "['amd64']" cpu: "['amd64']"

View File

@ -8,7 +8,7 @@ on:
jobs: jobs:
test_i386: test_i386:
name: Daily i386 (Linux) name: Daily i386 (Linux)
uses: ./.github/workflows/base_daily_tests.yml uses: ./.github/workflows/daily_common.yml
with: with:
nim: "[{'branch': 'version-1-6', 'memory_management': 'refc'}, {'branch': 'version-2-0', 'memory_management': 'refc'}, {'branch': 'devel', 'memory_management': 'orc'}]" nim: "[{'branch': 'version-1-6', 'memory_management': 'refc'}, {'branch': 'version-2-0', 'memory_management': 'refc'}, {'branch': 'devel', 'memory_management': 'orc'}]"
cpu: "['i386']" cpu: "['i386']"

View File

@ -1,7 +1,7 @@
mode = ScriptMode.Verbose mode = ScriptMode.Verbose
packageName = "libp2p" packageName = "libp2p"
version = "1.4.0" version = "1.5.0"
author = "Status Research & Development GmbH" author = "Status Research & Development GmbH"
description = "LibP2P implementation" description = "LibP2P implementation"
license = "MIT" license = "MIT"

View File

@ -136,7 +136,8 @@ proc triggerConnEvent*(c: ConnManager, peerId: PeerId, event: ConnEvent) {.async
except CancelledError as exc: except CancelledError as exc:
raise exc raise exc
except CatchableError as exc: except CatchableError as exc:
warn "Exception in triggerConnEvents", msg = exc.msg, peer = peerId, event = $event warn "Exception in triggerConnEvents",
description = exc.msg, peer = peerId, event = $event
proc addPeerEventHandler*( proc addPeerEventHandler*(
c: ConnManager, handler: PeerEventHandler, kind: PeerEventKind c: ConnManager, handler: PeerEventHandler, kind: PeerEventKind
@ -169,7 +170,7 @@ proc triggerPeerEvents*(c: ConnManager, peerId: PeerId, event: PeerEvent) {.asyn
except CancelledError as exc: except CancelledError as exc:
raise exc raise exc
except CatchableError as exc: # handlers should not raise! except CatchableError as exc: # handlers should not raise!
warn "Exception in triggerPeerEvents", exc = exc.msg, peer = peerId warn "Exception in triggerPeerEvents", description = exc.msg, peer = peerId
proc expectConnection*( proc expectConnection*(
c: ConnManager, p: PeerId, dir: Direction c: ConnManager, p: PeerId, dir: Direction
@ -212,7 +213,7 @@ proc closeMuxer(muxer: Muxer) {.async.} =
try: try:
await muxer.handler # TODO noraises? await muxer.handler # TODO noraises?
except CatchableError as exc: except CatchableError as exc:
trace "Exception in close muxer handler", exc = exc.msg trace "Exception in close muxer handler", description = exc.msg
trace "Cleaned up muxer", m = muxer trace "Cleaned up muxer", m = muxer
proc muxCleanup(c: ConnManager, mux: Muxer) {.async.} = proc muxCleanup(c: ConnManager, mux: Muxer) {.async.} =
@ -235,7 +236,7 @@ proc muxCleanup(c: ConnManager, mux: Muxer) {.async.} =
except CatchableError as exc: except CatchableError as exc:
# This is top-level procedure which will work as separate task, so it # This is top-level procedure which will work as separate task, so it
# do not need to propagate CancelledError and should handle other errors # do not need to propagate CancelledError and should handle other errors
warn "Unexpected exception peer cleanup handler", mux, msg = exc.msg warn "Unexpected exception peer cleanup handler", mux, description = exc.msg
proc onClose(c: ConnManager, mux: Muxer) {.async.} = proc onClose(c: ConnManager, mux: Muxer) {.async.} =
## connection close even handler ## connection close even handler
@ -246,7 +247,8 @@ proc onClose(c: ConnManager, mux: Muxer) {.async.} =
await mux.connection.join() await mux.connection.join()
trace "Connection closed, cleaning up", mux trace "Connection closed, cleaning up", mux
except CatchableError as exc: except CatchableError as exc:
debug "Unexpected exception in connection manager's cleanup", errMsg = exc.msg, mux debug "Unexpected exception in connection manager's cleanup",
description = exc.msg, mux
finally: finally:
await c.muxCleanup(mux) await c.muxCleanup(mux)
@ -358,7 +360,7 @@ proc trackConnection*(cs: ConnectionSlot, conn: Connection) =
try: try:
await conn.join() await conn.join()
except CatchableError as exc: except CatchableError as exc:
trace "Exception in semaphore monitor, ignoring", exc = exc.msg trace "Exception in semaphore monitor, ignoring", description = exc.msg
cs.release() cs.release()

View File

@ -62,10 +62,12 @@ proc dialAndUpgrade(
libp2p_total_dial_attempts.inc() libp2p_total_dial_attempts.inc()
await transport.dial(hostname, address, peerId) await transport.dial(hostname, address, peerId)
except CancelledError as exc: except CancelledError as exc:
trace "Dialing canceled", err = exc.msg, peerId = peerId.get(default(PeerId)) trace "Dialing canceled",
description = exc.msg, peerId = peerId.get(default(PeerId))
raise exc raise exc
except CatchableError as exc: except CatchableError as exc:
debug "Dialing failed", err = exc.msg, peerId = peerId.get(default(PeerId)) debug "Dialing failed",
description = exc.msg, peerId = peerId.get(default(PeerId))
libp2p_failed_dials.inc() libp2p_failed_dials.inc()
return nil # Try the next address return nil # Try the next address
@ -87,7 +89,7 @@ proc dialAndUpgrade(
# we won't succeeded through another - no use in trying again # we won't succeeded through another - no use in trying again
await dialed.close() await dialed.close()
debug "Connection upgrade failed", debug "Connection upgrade failed",
err = exc.msg, peerId = peerId.get(default(PeerId)) description = exc.msg, peerId = peerId.get(default(PeerId))
if dialed.dir == Direction.Out: if dialed.dir == Direction.Out:
libp2p_failed_upgrades_outgoing.inc() libp2p_failed_upgrades_outgoing.inc()
else: else:
@ -200,7 +202,7 @@ proc internalConnect(
PeerEvent(kind: PeerEventKind.Identified, initiator: true), PeerEvent(kind: PeerEventKind.Identified, initiator: true),
) )
except CatchableError as exc: except CatchableError as exc:
trace "Failed to finish outgoung upgrade", err = exc.msg trace "Failed to finish outgoung upgrade", description = exc.msg
await muxed.close() await muxed.close()
raise exc raise exc
@ -327,7 +329,7 @@ method dial*(
await cleanup() await cleanup()
raise exc raise exc
except CatchableError as exc: except CatchableError as exc:
debug "Error dialing", conn, err = exc.msg debug "Error dialing", conn, description = exc.msg
await cleanup() await cleanup()
raise exc raise exc

View File

@ -64,7 +64,7 @@ method advertise*(self: RendezVousInterface) {.async.} =
try: try:
await self.rdv.advertise(toAdv, self.ttl) await self.rdv.advertise(toAdv, self.ttl)
except CatchableError as error: except CatchableError as error:
debug "RendezVous advertise error: ", msg = error.msg debug "RendezVous advertise error: ", description = error.msg
await sleepAsync(self.timeToAdvertise) or self.advertisementUpdated.wait() await sleepAsync(self.timeToAdvertise) or self.advertisementUpdated.wait()

View File

@ -31,7 +31,7 @@ macro checkFutures*[F](futs: seq[F], exclude: untyped = []): untyped =
# We still don't abort but warn # We still don't abort but warn
debug "A future has failed, enable trace logging for details", debug "A future has failed, enable trace logging for details",
error = exc.name error = exc.name
trace "Exception message", msg = exc.msg, stack = getStackTrace() trace "Exception message", description = exc.msg, stack = getStackTrace()
else: else:
quote: quote:
for res in `futs`: for res in `futs`:
@ -40,9 +40,9 @@ macro checkFutures*[F](futs: seq[F], exclude: untyped = []): untyped =
let exc = res.readError() let exc = res.readError()
for i in 0 ..< `nexclude`: for i in 0 ..< `nexclude`:
if exc of `exclude`[i]: if exc of `exclude`[i]:
trace "A future has failed", error = exc.name, msg = exc.msg trace "A future has failed", error = exc.name, description = exc.msg
break check break check
# We still don't abort but warn # We still don't abort but warn
debug "A future has failed, enable trace logging for details", debug "A future has failed, enable trace logging for details",
error = exc.name error = exc.name
trace "Exception details", msg = exc.msg trace "Exception details", description = exc.msg

View File

@ -212,7 +212,7 @@ proc handle*(
except CancelledError as exc: except CancelledError as exc:
raise exc raise exc
except CatchableError as exc: except CatchableError as exc:
trace "Exception in multistream", conn, msg = exc.msg trace "Exception in multistream", conn, description = exc.msg
finally: finally:
await conn.close() await conn.close()

View File

@ -116,7 +116,7 @@ proc reset*(s: LPChannel) {.async: (raises: []).} =
trace "sending reset message", s, conn = s.conn trace "sending reset message", s, conn = s.conn
await noCancel s.conn.writeMsg(s.id, s.resetCode) # write reset await noCancel s.conn.writeMsg(s.id, s.resetCode) # write reset
except LPStreamError as exc: except LPStreamError as exc:
trace "Can't send reset message", s, conn = s.conn, msg = exc.msg trace "Can't send reset message", s, conn = s.conn, description = exc.msg
await s.conn.close() await s.conn.close()
asyncSpawn resetMessage() asyncSpawn resetMessage()
@ -145,7 +145,7 @@ method close*(s: LPChannel) {.async: (raises: []).} =
# It's harmless that close message cannot be sent - the connection is # It's harmless that close message cannot be sent - the connection is
# likely down already # likely down already
await s.conn.close() await s.conn.close()
trace "Cannot send close message", s, id = s.id, msg = exc.msg trace "Cannot send close message", s, id = s.id, description = exc.msg
await s.closeUnderlying() # maybe already eofed await s.closeUnderlying() # maybe already eofed
@ -256,7 +256,7 @@ proc completeWrite(
except LPStreamEOFError as exc: except LPStreamEOFError as exc:
raise exc raise exc
except LPStreamError as exc: except LPStreamError as exc:
trace "exception in lpchannel write handler", s, msg = exc.msg trace "exception in lpchannel write handler", s, description = exc.msg
await s.reset() await s.reset()
await s.conn.close() await s.conn.close()
raise newLPStreamConnDownError(exc) raise newLPStreamConnDownError(exc)

View File

@ -70,7 +70,7 @@ proc cleanupChann(m: Mplex, chann: LPChannel) {.async: (raises: []), inline.} =
labelValues = [$chann.initiator, $m.connection.peerId], labelValues = [$chann.initiator, $m.connection.peerId],
) )
except CancelledError as exc: except CancelledError as exc:
warn "Error cleaning up mplex channel", m, chann, msg = exc.msg warn "Error cleaning up mplex channel", m, chann, description = exc.msg
proc newStreamInternal*( proc newStreamInternal*(
m: Mplex, m: Mplex,
@ -175,7 +175,7 @@ method handle*(m: Mplex) {.async: (raises: []).} =
except LPStreamClosedError as exc: except LPStreamClosedError as exc:
# Channel is being closed, but `cleanupChann` was not yet triggered. # Channel is being closed, but `cleanupChann` was not yet triggered.
trace "pushing data to channel failed", trace "pushing data to channel failed",
m, channel, len = data.len, msg = exc.msg m, channel, len = data.len, description = exc.msg
discard # Ignore message, same as if `cleanupChann` had completed. discard # Ignore message, same as if `cleanupChann` had completed.
of MessageType.CloseIn, MessageType.CloseOut: of MessageType.CloseIn, MessageType.CloseOut:
await channel.pushEof() await channel.pushEof()
@ -185,11 +185,11 @@ method handle*(m: Mplex) {.async: (raises: []).} =
except CancelledError: except CancelledError:
debug "Unexpected cancellation in mplex handler", m debug "Unexpected cancellation in mplex handler", m
except LPStreamEOFError as exc: except LPStreamEOFError as exc:
trace "Stream EOF", m, msg = exc.msg trace "Stream EOF", m, description = exc.msg
except LPStreamError as exc: except LPStreamError as exc:
debug "Unexpected stream exception in mplex read loop", m, msg = exc.msg debug "Unexpected stream exception in mplex read loop", m, description = exc.msg
except MuxerError as exc: except MuxerError as exc:
debug "Unexpected muxer exception in mplex read loop", m, msg = exc.msg debug "Unexpected muxer exception in mplex read loop", m, description = exc.msg
finally: finally:
await m.close() await m.close()
trace "Stopped mplex handler", m trace "Stopped mplex handler", m

View File

@ -279,10 +279,15 @@ method readOnce*(
raise newLPStreamRemoteClosedError() raise newLPStreamRemoteClosedError()
if channel.recvQueue.len == 0: if channel.recvQueue.len == 0:
channel.receivedData.clear() channel.receivedData.clear()
try: # https://github.com/status-im/nim-chronos/issues/516 let
discard await race(channel.closedRemotely.wait(), channel.receivedData.wait()) closedRemotelyFut = channel.closedRemotely.wait()
except ValueError: receivedDataFut = channel.receivedData.wait()
raiseAssert("Futures list is not empty") defer:
if not closedRemotelyFut.finished():
await closedRemotelyFut.cancelAndWait()
if not receivedDataFut.finished():
await receivedDataFut.cancelAndWait()
await closedRemotelyFut or receivedDataFut
if channel.closedRemotely.isSet() and channel.recvQueue.len == 0: if channel.closedRemotely.isSet() and channel.recvQueue.len == 0:
channel.isEof = true channel.isEof = true
return return
@ -508,9 +513,9 @@ method close*(m: Yamux) {.async: (raises: []).} =
try: try:
await m.connection.write(YamuxHeader.goAway(NormalTermination)) await m.connection.write(YamuxHeader.goAway(NormalTermination))
except CancelledError as exc: except CancelledError as exc:
trace "cancelled sending goAway", msg = exc.msg trace "cancelled sending goAway", description = exc.msg
except LPStreamError as exc: except LPStreamError as exc:
trace "failed to send goAway", msg = exc.msg trace "failed to send goAway", description = exc.msg
await m.connection.close() await m.connection.close()
trace "Closed yamux" trace "Closed yamux"
@ -596,7 +601,7 @@ method handle*(m: Yamux) {.async: (raises: []).} =
if header.length > 0: if header.length > 0:
var buffer = newSeqUninitialized[byte](header.length) var buffer = newSeqUninitialized[byte](header.length)
await m.connection.readExactly(addr buffer[0], int(header.length)) await m.connection.readExactly(addr buffer[0], int(header.length))
trace "Msg Rcv", msg = shortLog(buffer) trace "Msg Rcv", description = shortLog(buffer)
await channel.gotDataFromRemote(buffer) await channel.gotDataFromRemote(buffer)
if MsgFlags.Fin in header.flags: if MsgFlags.Fin in header.flags:
@ -606,19 +611,19 @@ method handle*(m: Yamux) {.async: (raises: []).} =
trace "remote reset channel" trace "remote reset channel"
await channel.reset() await channel.reset()
except CancelledError as exc: except CancelledError as exc:
debug "Unexpected cancellation in yamux handler", msg = exc.msg debug "Unexpected cancellation in yamux handler", description = exc.msg
except LPStreamEOFError as exc: except LPStreamEOFError as exc:
trace "Stream EOF", msg = exc.msg trace "Stream EOF", description = exc.msg
except LPStreamError as exc: except LPStreamError as exc:
debug "Unexpected stream exception in yamux read loop", msg = exc.msg debug "Unexpected stream exception in yamux read loop", description = exc.msg
except YamuxError as exc: except YamuxError as exc:
trace "Closing yamux connection", error = exc.msg trace "Closing yamux connection", description = exc.msg
try: try:
await m.connection.write(YamuxHeader.goAway(ProtocolError)) await m.connection.write(YamuxHeader.goAway(ProtocolError))
except CancelledError, LPStreamError: except CancelledError, LPStreamError:
discard discard
except MuxerError as exc: except MuxerError as exc:
debug "Unexpected muxer exception in yamux read loop", msg = exc.msg debug "Unexpected muxer exception in yamux read loop", description = exc.msg
try: try:
await m.connection.write(YamuxHeader.goAway(ProtocolError)) await m.connection.write(YamuxHeader.goAway(ProtocolError))
except CancelledError, LPStreamError: except CancelledError, LPStreamError:

View File

@ -41,7 +41,7 @@ proc questionToBuf(address: string, kind: QKind): seq[byte] =
discard requestStream.readData(addr buf[0], dataLen) discard requestStream.readData(addr buf[0], dataLen)
return buf return buf
except CatchableError as exc: except CatchableError as exc:
info "Failed to created DNS buffer", msg = exc.msg info "Failed to created DNS buffer", description = exc.msg
return newSeq[byte](0) return newSeq[byte](0)
proc getDnsResponse( proc getDnsResponse(

View File

@ -84,13 +84,13 @@ proc tryDial(autonat: Autonat, conn: Connection, addrs: seq[MultiAddress]) {.asy
except CancelledError as exc: except CancelledError as exc:
raise exc raise exc
except AllFuturesFailedError as exc: except AllFuturesFailedError as exc:
debug "All dial attempts failed", addrs, exc = exc.msg debug "All dial attempts failed", addrs, description = exc.msg
await conn.sendResponseError(DialError, "All dial attempts failed") await conn.sendResponseError(DialError, "All dial attempts failed")
except AsyncTimeoutError as exc: except AsyncTimeoutError as exc:
debug "Dial timeout", addrs, exc = exc.msg debug "Dial timeout", addrs, description = exc.msg
await conn.sendResponseError(DialError, "Dial timeout") await conn.sendResponseError(DialError, "Dial timeout")
except CatchableError as exc: except CatchableError as exc:
debug "Unexpected error", addrs, exc = exc.msg debug "Unexpected error", addrs, description = exc.msg
await conn.sendResponseError(DialError, "Unexpected error") await conn.sendResponseError(DialError, "Unexpected error")
finally: finally:
autonat.sem.release() autonat.sem.release()
@ -165,7 +165,7 @@ proc new*(
except CancelledError as exc: except CancelledError as exc:
raise exc raise exc
except CatchableError as exc: except CatchableError as exc:
debug "exception in autonat handler", exc = exc.msg, conn debug "exception in autonat handler", description = exc.msg, conn
finally: finally:
trace "exiting autonat handler", conn trace "exiting autonat handler", conn
await conn.close() await conn.close()

View File

@ -146,13 +146,13 @@ proc askPeer(
debug "dialMe answer is reachable" debug "dialMe answer is reachable"
Reachable Reachable
except AutonatUnreachableError as error: except AutonatUnreachableError as error:
debug "dialMe answer is not reachable", msg = error.msg debug "dialMe answer is not reachable", description = error.msg
NotReachable NotReachable
except AsyncTimeoutError as error: except AsyncTimeoutError as error:
debug "dialMe timed out", msg = error.msg debug "dialMe timed out", description = error.msg
Unknown Unknown
except CatchableError as error: except CatchableError as error:
debug "dialMe unexpected error", msg = error.msg debug "dialMe unexpected error", description = error.msg
Unknown Unknown
let hasReachabilityOrConfidenceChanged = await self.handleAnswer(ans) let hasReachabilityOrConfidenceChanged = await self.handleAnswer(ans)
if hasReachabilityOrConfidenceChanged: if hasReachabilityOrConfidenceChanged:
@ -194,7 +194,7 @@ proc addressMapper(
processedMA = peerStore.guessDialableAddr(listenAddr) processedMA = peerStore.guessDialableAddr(listenAddr)
# handle manual port forwarding # handle manual port forwarding
except CatchableError as exc: except CatchableError as exc:
debug "Error while handling address mapper", msg = exc.msg debug "Error while handling address mapper", description = exc.msg
addrs.add(processedMA) addrs.add(processedMA)
return addrs return addrs

View File

@ -88,7 +88,7 @@ proc startSync*(
raise err raise err
except AllFuturesFailedError as err: except AllFuturesFailedError as err:
debug "Dcutr initiator could not connect to the remote peer, all connect attempts failed", debug "Dcutr initiator could not connect to the remote peer, all connect attempts failed",
peerDialableAddrs, msg = err.msg peerDialableAddrs, description = err.msg
raise newException( raise newException(
DcutrError, DcutrError,
"Dcutr initiator could not connect to the remote peer, all connect attempts failed", "Dcutr initiator could not connect to the remote peer, all connect attempts failed",
@ -96,7 +96,7 @@ proc startSync*(
) )
except AsyncTimeoutError as err: except AsyncTimeoutError as err:
debug "Dcutr initiator could not connect to the remote peer, all connect attempts timed out", debug "Dcutr initiator could not connect to the remote peer, all connect attempts timed out",
peerDialableAddrs, msg = err.msg peerDialableAddrs, description = err.msg
raise newException( raise newException(
DcutrError, DcutrError,
"Dcutr initiator could not connect to the remote peer, all connect attempts timed out", "Dcutr initiator could not connect to the remote peer, all connect attempts timed out",
@ -104,7 +104,7 @@ proc startSync*(
) )
except CatchableError as err: except CatchableError as err:
debug "Unexpected error when Dcutr initiator tried to connect to the remote peer", debug "Unexpected error when Dcutr initiator tried to connect to the remote peer",
err = err.msg description = err.msg
raise newException( raise newException(
DcutrError, DcutrError,
"Unexpected error when Dcutr initiator tried to connect to the remote peer", err, "Unexpected error when Dcutr initiator tried to connect to the remote peer", err,

View File

@ -80,13 +80,13 @@ proc new*(
raise err raise err
except AllFuturesFailedError as err: except AllFuturesFailedError as err:
debug "Dcutr receiver could not connect to the remote peer, " & debug "Dcutr receiver could not connect to the remote peer, " &
"all connect attempts failed", peerDialableAddrs, msg = err.msg "all connect attempts failed", peerDialableAddrs, description = err.msg
except AsyncTimeoutError as err: except AsyncTimeoutError as err:
debug "Dcutr receiver could not connect to the remote peer, " & debug "Dcutr receiver could not connect to the remote peer, " &
"all connect attempts timed out", peerDialableAddrs, msg = err.msg "all connect attempts timed out", peerDialableAddrs, description = err.msg
except CatchableError as err: except CatchableError as err:
warn "Unexpected error when Dcutr receiver tried to connect " & warn "Unexpected error when Dcutr receiver tried to connect " &
"to the remote peer", msg = err.msg "to the remote peer", description = err.msg
let self = T() let self = T()
self.handler = handleStream self.handler = handleStream

View File

@ -93,7 +93,7 @@ proc reserve*(
except CancelledError as exc: except CancelledError as exc:
raise exc raise exc
except CatchableError as exc: except CatchableError as exc:
trace "error writing or reading reservation message", exc = exc.msg trace "error writing or reading reservation message", description = exc.msg
raise newException(ReservationError, exc.msg) raise newException(ReservationError, exc.msg)
if msg.msgType != HopMessageType.Status: if msg.msgType != HopMessageType.Status:
@ -139,7 +139,7 @@ proc dialPeerV1*(
except CancelledError as exc: except CancelledError as exc:
raise exc raise exc
except CatchableError as exc: except CatchableError as exc:
trace "error writing hop request", exc = exc.msg trace "error writing hop request", description = exc.msg
raise exc raise exc
let msgRcvFromRelayOpt = let msgRcvFromRelayOpt =
@ -148,7 +148,7 @@ proc dialPeerV1*(
except CancelledError as exc: except CancelledError as exc:
raise exc raise exc
except CatchableError as exc: except CatchableError as exc:
trace "error reading stop response", exc = exc.msg trace "error reading stop response", description = exc.msg
await sendStatus(conn, StatusV1.HopCantOpenDstStream) await sendStatus(conn, StatusV1.HopCantOpenDstStream)
raise exc raise exc
@ -190,13 +190,13 @@ proc dialPeerV2*(
except CancelledError as exc: except CancelledError as exc:
raise exc raise exc
except CatchableError as exc: except CatchableError as exc:
trace "error reading stop response", exc = exc.msg trace "error reading stop response", description = exc.msg
raise newException(RelayV2DialError, exc.msg) raise newException(RelayV2DialError, exc.msg)
if msgRcvFromRelay.msgType != HopMessageType.Status: if msgRcvFromRelay.msgType != HopMessageType.Status:
raise newException(RelayV2DialError, "Unexpected stop response") raise newException(RelayV2DialError, "Unexpected stop response")
if msgRcvFromRelay.status.get(UnexpectedMessage) != Ok: if msgRcvFromRelay.status.get(UnexpectedMessage) != Ok:
trace "Relay stop failed", msg = msgRcvFromRelay.status trace "Relay stop failed", description = msgRcvFromRelay.status
raise newException(RelayV2DialError, "Relay stop failure") raise newException(RelayV2DialError, "Relay stop failure")
conn.limitDuration = msgRcvFromRelay.limit.duration conn.limitDuration = msgRcvFromRelay.limit.duration
conn.limitData = msgRcvFromRelay.limit.data conn.limitData = msgRcvFromRelay.limit.data
@ -302,7 +302,7 @@ proc new*(
except CancelledError as exc: except CancelledError as exc:
raise exc raise exc
except CatchableError as exc: except CatchableError as exc:
trace "exception in client handler", exc = exc.msg, conn trace "exception in client handler", description = exc.msg, conn
finally: finally:
trace "exiting client handler", conn trace "exiting client handler", conn
await conn.close() await conn.close()

View File

@ -167,7 +167,7 @@ proc handleConnect(r: Relay, connSrc: Connection, msg: HopMessage) {.async.} =
except CancelledError as exc: except CancelledError as exc:
raise exc raise exc
except CatchableError as exc: except CatchableError as exc:
trace "error opening relay stream", dst, exc = exc.msg trace "error opening relay stream", dst, description = exc.msg
await sendHopStatus(connSrc, ConnectionFailed) await sendHopStatus(connSrc, ConnectionFailed)
return return
defer: defer:
@ -196,7 +196,7 @@ proc handleConnect(r: Relay, connSrc: Connection, msg: HopMessage) {.async.} =
except CancelledError as exc: except CancelledError as exc:
raise exc raise exc
except CatchableError as exc: except CatchableError as exc:
trace "error sending stop message", msg = exc.msg trace "error sending stop message", description = exc.msg
await sendHopStatus(connSrc, ConnectionFailed) await sendHopStatus(connSrc, ConnectionFailed)
return return
@ -213,7 +213,7 @@ proc handleHopStreamV2*(r: Relay, conn: Connection) {.async.} =
let msg = HopMessage.decode(await conn.readLp(r.msgSize)).valueOr: let msg = HopMessage.decode(await conn.readLp(r.msgSize)).valueOr:
await sendHopStatus(conn, MalformedMessage) await sendHopStatus(conn, MalformedMessage)
return return
trace "relayv2 handle stream", msg = msg trace "relayv2 handle stream", hopMsg = msg
case msg.msgType case msg.msgType
of HopMessageType.Reserve: of HopMessageType.Reserve:
await r.handleReserve(conn) await r.handleReserve(conn)
@ -272,7 +272,7 @@ proc handleHop*(r: Relay, connSrc: Connection, msg: RelayMessage) {.async.} =
except CancelledError as exc: except CancelledError as exc:
raise exc raise exc
except CatchableError as exc: except CatchableError as exc:
trace "error opening relay stream", dst, exc = exc.msg trace "error opening relay stream", dst, description = exc.msg
await sendStatus(connSrc, StatusV1.HopCantDialDst) await sendStatus(connSrc, StatusV1.HopCantDialDst)
return return
defer: defer:
@ -289,12 +289,13 @@ proc handleHop*(r: Relay, connSrc: Connection, msg: RelayMessage) {.async.} =
except CancelledError as exc: except CancelledError as exc:
raise exc raise exc
except CatchableError as exc: except CatchableError as exc:
trace "error writing stop handshake or reading stop response", exc = exc.msg trace "error writing stop handshake or reading stop response",
description = exc.msg
await sendStatus(connSrc, StatusV1.HopCantOpenDstStream) await sendStatus(connSrc, StatusV1.HopCantOpenDstStream)
return return
let msgRcvFromDst = msgRcvFromDstOpt.valueOr: let msgRcvFromDst = msgRcvFromDstOpt.valueOr:
trace "error reading stop response", msg = msgRcvFromDstOpt trace "error reading stop response", response = msgRcvFromDstOpt
await sendStatus(connSrc, StatusV1.HopCantOpenDstStream) await sendStatus(connSrc, StatusV1.HopCantOpenDstStream)
return return
@ -369,7 +370,7 @@ proc new*(
except CancelledError as exc: except CancelledError as exc:
raise exc raise exc
except CatchableError as exc: except CatchableError as exc:
debug "exception in relayv2 handler", exc = exc.msg, conn debug "exception in relayv2 handler", description = exc.msg, conn
finally: finally:
trace "exiting relayv2 handler", conn trace "exiting relayv2 handler", conn
await conn.close() await conn.close()

View File

@ -87,7 +87,7 @@ proc bridge*(
trace "relay src closed connection", src = connSrc.peerId trace "relay src closed connection", src = connSrc.peerId
if connDst.closed() or connDst.atEof(): if connDst.closed() or connDst.atEof():
trace "relay dst closed connection", dst = connDst.peerId trace "relay dst closed connection", dst = connDst.peerId
trace "relay error", exc = exc.msg trace "relay error", description = exc.msg
trace "end relaying", bytesSentFromSrcToDst, bytesSentFromDstToSrc trace "end relaying", bytesSentFromSrcToDst, bytesSentFromDstToSrc
await futSrc.cancelAndWait() await futSrc.cancelAndWait()
await futDst.cancelAndWait() await futDst.cancelAndWait()

View File

@ -156,7 +156,7 @@ method init*(p: Identify) =
except CancelledError as exc: except CancelledError as exc:
raise exc raise exc
except CatchableError as exc: except CatchableError as exc:
trace "exception in identify handler", exc = exc.msg, conn trace "exception in identify handler", description = exc.msg, conn
finally: finally:
trace "exiting identify handler", conn trace "exiting identify handler", conn
await conn.closeWithEOF() await conn.closeWithEOF()
@ -226,7 +226,7 @@ proc init*(p: IdentifyPush) =
except CancelledError as exc: except CancelledError as exc:
raise exc raise exc
except CatchableError as exc: except CatchableError as exc:
info "exception in identify push handler", exc = exc.msg, conn info "exception in identify push handler", description = exc.msg, conn
finally: finally:
trace "exiting identify push handler", conn trace "exiting identify push handler", conn
await conn.closeWithEOF() await conn.closeWithEOF()

View File

@ -49,7 +49,7 @@ proc new*(T: typedesc[Perf]): T {.public.} =
except CancelledError as exc: except CancelledError as exc:
raise exc raise exc
except CatchableError as exc: except CatchableError as exc:
trace "exception in perf handler", exc = exc.msg, conn trace "exception in perf handler", description = exc.msg, conn
await conn.close() await conn.close()
p.handler = handle p.handler = handle

View File

@ -63,7 +63,7 @@ method init*(p: Ping) =
except CancelledError as exc: except CancelledError as exc:
raise exc raise exc
except CatchableError as exc: except CatchableError as exc:
trace "exception in ping handler", exc = exc.msg, conn trace "exception in ping handler", description = exc.msg, conn
p.handler = handle p.handler = handle
p.codec = PingCodec p.codec = PingCodec

View File

@ -106,7 +106,7 @@ method rpcHandler*(f: FloodSub, peer: PubSubPeer, data: seq[byte]) {.async.} =
debug "failed to decode msg from peer", peer, err = error debug "failed to decode msg from peer", peer, err = error
raise newException(CatchableError, "Peer msg couldn't be decoded") raise newException(CatchableError, "Peer msg couldn't be decoded")
trace "decoded msg from peer", peer, msg = rpcMsg.shortLog trace "decoded msg from peer", peer, payload = rpcMsg.shortLog
# trigger hooks # trigger hooks
peer.recvObservers(rpcMsg) peer.recvObservers(rpcMsg)
@ -187,7 +187,7 @@ method init*(f: FloodSub) =
# do not need to propagate CancelledError. # do not need to propagate CancelledError.
trace "Unexpected cancellation in floodsub handler", conn trace "Unexpected cancellation in floodsub handler", conn
except CatchableError as exc: except CatchableError as exc:
trace "FloodSub handler leaks an error", exc = exc.msg, conn trace "FloodSub handler leaks an error", description = exc.msg, conn
f.handler = handler f.handler = handler
f.codec = FloodSubCodec f.codec = FloodSubCodec
@ -219,7 +219,7 @@ method publish*(f: FloodSub, topic: string, data: seq[byte]): Future[int] {.asyn
trace "Error generating message id, skipping publish", error = error trace "Error generating message id, skipping publish", error = error
return 0 return 0
trace "Created new message", msg = shortLog(msg), peers = peers.len, topic, msgId trace "Created new message", payload = shortLog(msg), peers = peers.len, topic, msgId
if f.addSeen(f.salt(msgId)): if f.addSeen(f.salt(msgId)):
# custom msgid providers might cause this # custom msgid providers might cause this

View File

@ -220,7 +220,7 @@ method init*(g: GossipSub) =
# do not need to propogate CancelledError. # do not need to propogate CancelledError.
trace "Unexpected cancellation in gossipsub handler", conn trace "Unexpected cancellation in gossipsub handler", conn
except CatchableError as exc: except CatchableError as exc:
trace "GossipSub handler leaks an error", exc = exc.msg, conn trace "GossipSub handler leaks an error", description = exc.msg, conn
g.handler = handler g.handler = handler
g.codecs &= GossipSubCodec_12 g.codecs &= GossipSubCodec_12
@ -368,7 +368,7 @@ proc handleControl(g: GossipSub, peer: PubSubPeer, control: ControlMessage) =
else: else:
libp2p_pubsub_broadcast_prune.inc(labelValues = ["generic"]) libp2p_pubsub_broadcast_prune.inc(labelValues = ["generic"])
trace "sending control message", msg = shortLog(respControl), peer trace "sending control message", payload = shortLog(respControl), peer
g.send(peer, RPCMsg(control: some(respControl)), isHighPriority = true) g.send(peer, RPCMsg(control: some(respControl)), isHighPriority = true)
if messages.len > 0: if messages.len > 0:
@ -491,7 +491,7 @@ proc validateAndRelay(
await handleData(g, topic, msg.data) await handleData(g, topic, msg.data)
except CatchableError as exc: except CatchableError as exc:
info "validateAndRelay failed", msg = exc.msg info "validateAndRelay failed", description = exc.msg
proc dataAndTopicsIdSize(msgs: seq[Message]): int = proc dataAndTopicsIdSize(msgs: seq[Message]): int =
msgs.mapIt(it.data.len + it.topic.len).foldl(a + b, 0) msgs.mapIt(it.data.len + it.topic.len).foldl(a + b, 0)
@ -540,7 +540,7 @@ method rpcHandler*(g: GossipSub, peer: PubSubPeer, data: seq[byte]) {.async.} =
for m in rpcMsg.messages: for m in rpcMsg.messages:
libp2p_pubsub_received_messages.inc(labelValues = [$peer.peerId, m.topic]) libp2p_pubsub_received_messages.inc(labelValues = [$peer.peerId, m.topic])
trace "decoded msg from peer", peer, msg = rpcMsg.shortLog trace "decoded msg from peer", peer, payload = rpcMsg.shortLog
await rateLimit(g, peer, g.messageOverhead(rpcMsg, msgSize)) await rateLimit(g, peer, g.messageOverhead(rpcMsg, msgSize))
# trigger hooks - these may modify the message # trigger hooks - these may modify the message
@ -771,7 +771,7 @@ method publish*(g: GossipSub, topic: string, data: seq[byte]): Future[int] {.asy
logScope: logScope:
msgId = shortLog(msgId) msgId = shortLog(msgId)
trace "Created new message", msg = shortLog(msg), peers = peers.len trace "Created new message", payload = shortLog(msg), peers = peers.len
if g.addSeen(g.salt(msgId)): if g.addSeen(g.salt(msgId)):
# If the message was received or published recently, don't re-publish it - # If the message was received or published recently, don't re-publish it -
@ -806,7 +806,7 @@ proc maintainDirectPeer(g: GossipSub, id: PeerId, addrs: seq[MultiAddress]) {.as
trace "Direct peer dial canceled" trace "Direct peer dial canceled"
raise exc raise exc
except CatchableError as exc: except CatchableError as exc:
debug "Direct peer error dialing", msg = exc.msg debug "Direct peer error dialing", description = exc.msg
proc addDirectPeer*(g: GossipSub, id: PeerId, addrs: seq[MultiAddress]) {.async.} = proc addDirectPeer*(g: GossipSub, id: PeerId, addrs: seq[MultiAddress]) {.async.} =
g.parameters.directPeers[id] = addrs g.parameters.directPeers[id] = addrs

View File

@ -135,7 +135,7 @@ proc disconnectPeer*(g: GossipSub, peer: PubSubPeer) {.async.} =
try: try:
await g.switch.disconnect(peer.peerId) await g.switch.disconnect(peer.peerId)
except CatchableError as exc: # Never cancelled except CatchableError as exc: # Never cancelled
trace "Failed to close connection", peer, error = exc.name, msg = exc.msg trace "Failed to close connection", peer, errName = exc.name, description = exc.msg
proc disconnectIfBadScorePeer*(g: GossipSub, peer: PubSubPeer, score: float64) = proc disconnectIfBadScorePeer*(g: GossipSub, peer: PubSubPeer, score: float64) =
if g.parameters.disconnectBadPeers and score < g.parameters.graylistThreshold and if g.parameters.disconnectBadPeers and score < g.parameters.graylistThreshold and

View File

@ -197,7 +197,7 @@ proc send*(
## High priority messages are sent immediately, while low priority messages are queued and sent only after all high ## High priority messages are sent immediately, while low priority messages are queued and sent only after all high
## priority messages have been sent. ## priority messages have been sent.
trace "sending pubsub message to peer", peer, msg = shortLog(msg) trace "sending pubsub message to peer", peer, payload = shortLog(msg)
peer.send(msg, p.anonymize, isHighPriority) peer.send(msg, p.anonymize, isHighPriority)
proc broadcast*( proc broadcast*(
@ -255,7 +255,7 @@ proc broadcast*(
else: else:
libp2p_pubsub_broadcast_prune.inc(npeers, labelValues = ["generic"]) libp2p_pubsub_broadcast_prune.inc(npeers, labelValues = ["generic"])
trace "broadcasting messages to peers", peers = sendPeers.len, msg = shortLog(msg) trace "broadcasting messages to peers", peers = sendPeers.len, payload = shortLog(msg)
if anyIt(sendPeers, it.hasObservers): if anyIt(sendPeers, it.hasObservers):
for peer in sendPeers: for peer in sendPeers:
@ -403,7 +403,7 @@ proc handleData*(p: PubSub, topic: string, data: seq[byte]): Future[void] =
for fut in futs: for fut in futs:
if fut.failed: if fut.failed:
let err = fut.readError() let err = fut.readError()
warn "Error in topic handler", msg = err.msg warn "Error in topic handler", description = err.msg
return waiter() return waiter()
@ -437,7 +437,7 @@ method handleConn*(p: PubSub, conn: Connection, proto: string) {.base, async.} =
except CancelledError as exc: except CancelledError as exc:
raise exc raise exc
except CatchableError as exc: except CatchableError as exc:
trace "exception ocurred in pubsub handle", exc = exc.msg, conn trace "exception ocurred in pubsub handle", description = exc.msg, conn
finally: finally:
await conn.closeWithEOF() await conn.closeWithEOF()

View File

@ -205,10 +205,10 @@ proc handle*(p: PubSubPeer, conn: Connection) {.async.} =
data = newSeq[byte]() # Release memory data = newSeq[byte]() # Release memory
except PeerRateLimitError as exc: except PeerRateLimitError as exc:
debug "Peer rate limit exceeded, exiting read while", debug "Peer rate limit exceeded, exiting read while",
conn, peer = p, error = exc.msg conn, peer = p, description = exc.msg
except CatchableError as exc: except CatchableError as exc:
debug "Exception occurred in PubSubPeer.handle", debug "Exception occurred in PubSubPeer.handle",
conn, peer = p, closed = conn.closed, exc = exc.msg conn, peer = p, closed = conn.closed, description = exc.msg
finally: finally:
await conn.close() await conn.close()
except CancelledError: except CancelledError:
@ -217,7 +217,7 @@ proc handle*(p: PubSubPeer, conn: Connection) {.async.} =
trace "Unexpected cancellation in PubSubPeer.handle" trace "Unexpected cancellation in PubSubPeer.handle"
except CatchableError as exc: except CatchableError as exc:
trace "Exception occurred in PubSubPeer.handle", trace "Exception occurred in PubSubPeer.handle",
conn, peer = p, closed = conn.closed, exc = exc.msg conn, peer = p, closed = conn.closed, description = exc.msg
finally: finally:
debug "exiting pubsub read loop", conn, peer = p, closed = conn.closed debug "exiting pubsub read loop", conn, peer = p, closed = conn.closed
@ -236,7 +236,7 @@ proc closeSendConn(p: PubSubPeer, event: PubSubPeerEventKind) {.async.} =
except CancelledError as exc: except CancelledError as exc:
raise exc raise exc
except CatchableError as exc: except CatchableError as exc:
debug "Errors during diconnection events", error = exc.msg debug "Errors during diconnection events", description = exc.msg
# don't cleanup p.address else we leak some gossip stat table # don't cleanup p.address else we leak some gossip stat table
proc connectOnce(p: PubSubPeer): Future[void] {.async.} = proc connectOnce(p: PubSubPeer): Future[void] {.async.} =
@ -283,7 +283,7 @@ proc connectImpl(p: PubSubPeer) {.async.} =
return return
await connectOnce(p) await connectOnce(p)
except CatchableError as exc: # never cancelled except CatchableError as exc: # never cancelled
debug "Could not establish send connection", msg = exc.msg debug "Could not establish send connection", description = exc.msg
proc connect*(p: PubSubPeer) = proc connect*(p: PubSubPeer) =
if p.connected: if p.connected:
@ -325,7 +325,7 @@ proc sendMsgContinue(conn: Connection, msgFut: Future[void]) {.async.} =
except CatchableError as exc: # never cancelled except CatchableError as exc: # never cancelled
# Because we detach the send call from the currently executing task using # Because we detach the send call from the currently executing task using
# asyncSpawn, no exceptions may leak out of it # asyncSpawn, no exceptions may leak out of it
trace "Unable to send to remote", conn, msg = exc.msg trace "Unable to send to remote", conn, description = exc.msg
# Next time sendConn is used, it will be have its close flag set and thus # Next time sendConn is used, it will be have its close flag set and thus
# will be recycled # will be recycled
@ -341,7 +341,7 @@ proc sendMsgSlow(p: PubSubPeer, msg: seq[byte]) {.async.} =
var conn = p.sendConn var conn = p.sendConn
if conn == nil or conn.closed(): if conn == nil or conn.closed():
debug "No send connection", p, msg = shortLog(msg) debug "No send connection", p, payload = shortLog(msg)
return return
trace "sending encoded msg to peer", conn, encoded = shortLog(msg) trace "sending encoded msg to peer", conn, encoded = shortLog(msg)
@ -383,7 +383,7 @@ proc sendEncoded*(p: PubSubPeer, msg: seq[byte], isHighPriority: bool): Future[v
) == 0 ) == 0
if msg.len <= 0: if msg.len <= 0:
debug "empty message, skipping", p, msg = shortLog(msg) debug "empty message, skipping", p, payload = shortLog(msg)
Future[void].completed() Future[void].completed()
elif msg.len > p.maxMessageSize: elif msg.len > p.maxMessageSize:
info "trying to send a msg too big for pubsub", info "trying to send a msg too big for pubsub",

View File

@ -310,7 +310,7 @@ proc decodeMessages*(pb: ProtoBuffer): ProtoResult[seq[Message]] {.inline.} =
ok(msgs) ok(msgs)
proc encodeRpcMsg*(msg: RPCMsg, anonymize: bool): seq[byte] = proc encodeRpcMsg*(msg: RPCMsg, anonymize: bool): seq[byte] =
trace "encodeRpcMsg: encoding message", msg = msg.shortLog() trace "encodeRpcMsg: encoding message", payload = msg.shortLog()
var pb = initProtoBuffer(maxSize = uint.high) var pb = initProtoBuffer(maxSize = uint.high)
for item in msg.subscriptions: for item in msg.subscriptions:
pb.write(1, item) pb.write(1, item)
@ -329,7 +329,7 @@ proc encodeRpcMsg*(msg: RPCMsg, anonymize: bool): seq[byte] =
pb.buffer pb.buffer
proc decodeRpcMsg*(msg: seq[byte]): ProtoResult[RPCMsg] {.inline.} = proc decodeRpcMsg*(msg: seq[byte]): ProtoResult[RPCMsg] {.inline.} =
trace "decodeRpcMsg: decoding message", msg = msg.shortLog() trace "decodeRpcMsg: decoding message", payload = msg.shortLog()
var pb = initProtoBuffer(msg, maxSize = uint.high) var pb = initProtoBuffer(msg, maxSize = uint.high)
var rpcMsg = RPCMsg() var rpcMsg = RPCMsg()
assign(rpcMsg.messages, ?pb.decodeMessages()) assign(rpcMsg.messages, ?pb.decodeMessages())

View File

@ -499,7 +499,7 @@ proc advertisePeer(rdv: RendezVous, peer: PeerId, msg: seq[byte]) {.async.} =
else: else:
trace "Successfully registered", peer, response = msgRecv.registerResponse trace "Successfully registered", peer, response = msgRecv.registerResponse
except CatchableError as exc: except CatchableError as exc:
trace "exception in the advertise", error = exc.msg trace "exception in the advertise", description = exc.msg
finally: finally:
rdv.sema.release() rdv.sema.release()
@ -618,7 +618,7 @@ proc request*(
except CancelledError as exc: except CancelledError as exc:
raise exc raise exc
except CatchableError as exc: except CatchableError as exc:
trace "exception catch in request", error = exc.msg trace "exception catch in request", description = exc.msg
return toSeq(s.values()).mapIt(it[0]) return toSeq(s.values()).mapIt(it[0])
proc unsubscribeLocally*(rdv: RendezVous, ns: string) = proc unsubscribeLocally*(rdv: RendezVous, ns: string) =
@ -646,7 +646,7 @@ proc unsubscribe*(rdv: RendezVous, ns: string) {.async.} =
await conn.close() await conn.close()
await conn.writeLp(msg.buffer) await conn.writeLp(msg.buffer)
except CatchableError as exc: except CatchableError as exc:
trace "exception while unsubscribing", error = exc.msg trace "exception while unsubscribing", description = exc.msg
for peer in rdv.peers: for peer in rdv.peers:
discard await rdv.unsubscribePeer(peer).withTimeout(5.seconds) discard await rdv.unsubscribePeer(peer).withTimeout(5.seconds)
@ -692,7 +692,7 @@ proc new*(T: typedesc[RendezVous], rng: ref HmacDrbgContext = newRng()): T =
except CancelledError as exc: except CancelledError as exc:
raise exc raise exc
except CatchableError as exc: except CatchableError as exc:
trace "exception in rendezvous handler", error = exc.msg trace "exception in rendezvous handler", description = exc.msg
finally: finally:
await conn.close() await conn.close()

View File

@ -155,7 +155,7 @@ method init*(s: Secure) =
await conn.close() await conn.close()
raise exc raise exc
except LPStreamError as exc: except LPStreamError as exc:
warn "securing connection failed", err = exc.msg, conn warn "securing connection failed", description = exc.msg, conn
await conn.close() await conn.close()
s.handler = handle s.handler = handle

View File

@ -326,4 +326,4 @@ proc closeWithEOF*(s: LPStream): Future[void] {.async: (raises: []), public.} =
except LPStreamEOFError: except LPStreamEOFError:
trace "Expected EOF came", s trace "Expected EOF came", s
except LPStreamError as exc: except LPStreamError as exc:
debug "Unexpected error while waiting for EOF", s, msg = exc.msg debug "Unexpected error while waiting for EOF", s, description = exc.msg

View File

@ -219,7 +219,7 @@ proc upgradeMonitor(
libp2p_failed_upgrades_incoming.inc() libp2p_failed_upgrades_incoming.inc()
if not isNil(conn): if not isNil(conn):
await conn.close() await conn.close()
trace "Exception awaiting connection upgrade", exc = exc.msg, conn trace "Exception awaiting connection upgrade", description = exc.msg, conn
finally: finally:
upgrades.release() upgrades.release()
@ -264,7 +264,7 @@ proc accept(s: Switch, transport: Transport) {.async.} = # noraises
upgrades.release() # always release the slot upgrades.release() # always release the slot
return return
except CatchableError as exc: except CatchableError as exc:
error "Exception in accept loop, exiting", exc = exc.msg error "Exception in accept loop, exiting", description = exc.msg
upgrades.release() # always release the slot upgrades.release() # always release the slot
if not isNil(conn): if not isNil(conn):
await conn.close() await conn.close()
@ -282,7 +282,7 @@ proc stop*(s: Switch) {.async, public.} =
# Stop accepting incoming connections # Stop accepting incoming connections
await allFutures(s.acceptFuts.mapIt(it.cancelAndWait())).wait(1.seconds) await allFutures(s.acceptFuts.mapIt(it.cancelAndWait())).wait(1.seconds)
except CatchableError as exc: except CatchableError as exc:
debug "Cannot cancel accepts", error = exc.msg debug "Cannot cancel accepts", description = exc.msg
for service in s.services: for service in s.services:
discard await service.stop(s) discard await service.stop(s)
@ -296,7 +296,7 @@ proc stop*(s: Switch) {.async, public.} =
except CancelledError as exc: except CancelledError as exc:
raise exc raise exc
except CatchableError as exc: except CatchableError as exc:
warn "error cleaning up transports", msg = exc.msg warn "error cleaning up transports", description = exc.msg
await s.ms.stop() await s.ms.stop()

View File

@ -249,10 +249,10 @@ method accept*(self: TcpTransport): Future[Connection] =
try: try:
await finished await finished
except TransportTooManyError as exc: except TransportTooManyError as exc:
debug "Too many files opened", exc = exc.msg debug "Too many files opened", description = exc.msg
return nil return nil
except TransportAbortedError as exc: except TransportAbortedError as exc:
debug "Connection aborted", exc = exc.msg debug "Connection aborted", description = exc.msg
return nil return nil
except TransportUseClosedError as exc: except TransportUseClosedError as exc:
raise newTransportClosedError(exc) raise newTransportClosedError(exc)
@ -273,7 +273,7 @@ method accept*(self: TcpTransport): Future[Connection] =
except TransportOsError as exc: except TransportOsError as exc:
# The connection had errors / was closed before `await` returned control # The connection had errors / was closed before `await` returned control
await transp.closeWait() await transp.closeWait()
debug "Cannot read remote address", exc = exc.msg debug "Cannot read remote address", description = exc.msg
return nil return nil
let observedAddr = let observedAddr =

View File

@ -206,7 +206,7 @@ method stop*(self: WsTransport) {.async.} =
self.httpservers = @[] self.httpservers = @[]
trace "Transport stopped" trace "Transport stopped"
except CatchableError as exc: except CatchableError as exc:
trace "Error shutting down ws transport", exc = exc.msg trace "Error shutting down ws transport", description = exc.msg
proc connHandler( proc connHandler(
self: WsTransport, stream: WSSession, secure: bool, dir: Direction self: WsTransport, stream: WSSession, secure: bool, dir: Direction
@ -223,7 +223,7 @@ proc connHandler(
MultiAddress.init(remoteAddr).tryGet() & codec.tryGet() MultiAddress.init(remoteAddr).tryGet() & codec.tryGet()
except CatchableError as exc: except CatchableError as exc:
trace "Failed to create observedAddr", exc = exc.msg trace "Failed to create observedAddr", description = exc.msg
if not (isNil(stream) and stream.stream.reader.closed): if not (isNil(stream) and stream.stream.reader.closed):
await stream.close() await stream.close()
raise exc raise exc
@ -271,26 +271,26 @@ method accept*(self: WsTransport): Future[Connection] {.async.} =
await req.stream.closeWait() await req.stream.closeWait()
raise exc raise exc
except WebSocketError as exc: except WebSocketError as exc:
debug "Websocket Error", exc = exc.msg debug "Websocket Error", description = exc.msg
except HttpError as exc: except HttpError as exc:
debug "Http Error", exc = exc.msg debug "Http Error", description = exc.msg
except AsyncStreamError as exc: except AsyncStreamError as exc:
debug "AsyncStream Error", exc = exc.msg debug "AsyncStream Error", description = exc.msg
except TransportTooManyError as exc: except TransportTooManyError as exc:
debug "Too many files opened", exc = exc.msg debug "Too many files opened", description = exc.msg
except TransportAbortedError as exc: except TransportAbortedError as exc:
debug "Connection aborted", exc = exc.msg debug "Connection aborted", description = exc.msg
except AsyncTimeoutError as exc: except AsyncTimeoutError as exc:
debug "Timed out", exc = exc.msg debug "Timed out", description = exc.msg
except TransportUseClosedError as exc: except TransportUseClosedError as exc:
debug "Server was closed", exc = exc.msg debug "Server was closed", description = exc.msg
raise newTransportClosedError(exc) raise newTransportClosedError(exc)
except CancelledError as exc: except CancelledError as exc:
raise exc raise exc
except TransportOsError as exc: except TransportOsError as exc:
debug "OS Error", exc = exc.msg debug "OS Error", description = exc.msg
except CatchableError as exc: except CatchableError as exc:
info "Unexpected error accepting connection", exc = exc.msg info "Unexpected error accepting connection", description = exc.msg
raise exc raise exc
method dial*( method dial*(

View File

@ -120,7 +120,7 @@ proc main() {.async.} =
echo &"""{{"rtt_to_holepunched_peer_millis":{delay.millis}}}""" echo &"""{{"rtt_to_holepunched_peer_millis":{delay.millis}}}"""
quit(0) quit(0)
except CatchableError as e: except CatchableError as e:
error "Unexpected error", msg = e.msg error "Unexpected error", description = e.msg
discard waitFor(main().withTimeout(4.minutes)) discard waitFor(main().withTimeout(4.minutes))
quit(1) quit(1)