Skip to content
4 changes: 2 additions & 2 deletions packages/connection-encrypter-plaintext/src/index.ts
Original file line number Diff line number Diff line change
Expand Up @@ -104,8 +104,8 @@ class Plaintext implements ConnectionEncrypter {
throw new InvalidCryptoExchangeError('Public key did not match id')
}
} catch (err: any) {
log.error(err)
throw new InvalidCryptoExchangeError('Invalid public key - ' + err.message)
log.error('invalid public key - %e', err)
throw new InvalidCryptoExchangeError(`Invalid public key - ${err.message}`)
}

if (options?.remotePeer != null && !peerId.equals(options?.remotePeer)) {
Expand Down
2 changes: 1 addition & 1 deletion packages/connection-encrypter-tls/src/tls.ts
Original file line number Diff line number Diff line change
Expand Up @@ -179,7 +179,7 @@ export class TLS implements ConnectionEncrypter {

if (streamMuxer == null) {
const err = new InvalidCryptoExchangeError(`Selected muxer ${socket.alpnProtocol} did not exist`)
log.error(`Selected muxer ${socket.alpnProtocol} did not exist - %e`, err)
log.error('selected muxer %s did not exist - %e', socket.alpnProtocol, err)

connection.abort(err)
reject(err)
Expand Down
10 changes: 5 additions & 5 deletions packages/floodsub/src/floodsub.ts
Original file line number Diff line number Diff line change
Expand Up @@ -341,7 +341,7 @@ export class FloodSub extends TypedEventEmitter<FloodSubEvents> implements Flood

await this.processMessage(peerStream.peerId, msg)
} catch (err: any) {
this.log.error(err)
this.log.error('failed to queue messages from %p - %e', peerStream.peerId, err)
}
}))
.catch(err => { this.log(err) })
Expand Down Expand Up @@ -466,15 +466,15 @@ export class FloodSub extends TypedEventEmitter<FloodSubEvents> implements Flood
* Send an rpc object to a peer
*/
sendRpc (peer: PeerId, rpc: PubSubRPC): void {
const peerStream = this.peers.get(peer)
const peerStreams = this.peers.get(peer)

if (peerStream == null) {
this.log.error('Cannot send RPC to %p as there are no streams to it available', peer)
if (peerStreams == null) {
this.log.error('cannot send RPC to %p as there are no streams to it available', peer)

return
}

peerStream.write(rpc)
peerStreams.write(rpc)
}

/**
Expand Down
4 changes: 2 additions & 2 deletions packages/kad-dht/src/content-fetching/index.ts
Original file line number Diff line number Diff line change
Expand Up @@ -106,7 +106,7 @@ export class ContentFetching {
this.log(`Storing corrected record for key ${dsKey.toString()}`)
await this.components.datastore.put(dsKey, fixupRec.subarray(), options)
} catch (err: any) {
this.log.error('Failed error correcting self', err)
this.log.error('failed error correcting self - %e', err)
}

continue
Expand All @@ -132,7 +132,7 @@ export class ContentFetching {
throw new QueryError('Could not send correction')
}

this.log.error('Failed error correcting entry')
this.log.error('failed error correcting entry')
}
}

Expand Down
2 changes: 1 addition & 1 deletion packages/kad-dht/src/content-routing/index.ts
Original file line number Diff line number Diff line change
Expand Up @@ -115,7 +115,7 @@ export class ContentRouting {
yield addProviderEvent
}
} catch (err: any) {
self.log.error('error sending provide record to peer %p', event.peer.id, err)
self.log.error('error sending provide record to peer %p - %e', event.peer.id, err)
yield queryErrorEvent({
from: event.peer.id,
error: err,
Expand Down
8 changes: 4 additions & 4 deletions packages/kad-dht/src/kad-dht.ts
Original file line number Diff line number Diff line change
Expand Up @@ -298,7 +298,7 @@ export class KadDHT extends TypedEventEmitter<PeerDiscoveryEvents> implements Ka
const peerData = evt.detail

this.onPeerConnect(peerData).catch(err => {
this.log.error('could not add %p to routing table', peerData.id, err)
this.log.error('could not add %p to routing table - %e', peerData.id, err)
})

this.dispatchEvent(new CustomEvent('peer', {
Expand All @@ -321,7 +321,7 @@ export class KadDHT extends TypedEventEmitter<PeerDiscoveryEvents> implements Ka

await this.onPeerConnect(peerData)
}).catch(err => {
this.log.error('could not add %p to routing table - %e - %e', peerId, err)
this.log.error('could not add %p to routing table - %e', peerId, err)
})
})

Expand Down Expand Up @@ -350,7 +350,7 @@ export class KadDHT extends TypedEventEmitter<PeerDiscoveryEvents> implements Ka
}
})
.catch(err => {
this.log.error('error setting dht server mode', err)
this.log.error('error setting dht server mode - %e', err)
})
})
}
Expand Down Expand Up @@ -407,7 +407,7 @@ export class KadDHT extends TypedEventEmitter<PeerDiscoveryEvents> implements Ka
signal
})
} catch (err: any) {
this.log.error('could not add %p to routing table', peerData.id, err)
this.log.error('could not add %p to routing table - %e', peerData.id, err)
}
}

Expand Down
4 changes: 2 additions & 2 deletions packages/kad-dht/src/network.ts
Original file line number Diff line number Diff line change
Expand Up @@ -186,7 +186,7 @@ export class Network extends TypedEventEmitter<NetworkEvents> implements Startab

stream.close(options)
.catch(err => {
this.log.error('error closing stream to %p', to, err)
this.log.error('error closing stream to %p - %e', to, err)
stream?.abort(err)
})

Expand Down Expand Up @@ -252,7 +252,7 @@ export class Network extends TypedEventEmitter<NetworkEvents> implements Startab

stream.close(options)
.catch(err => {
this.log.error('error closing stream to %p', to, err)
this.log.error('error closing stream to %p - %e', to, err)
stream?.abort(err)
})

Expand Down
6 changes: 3 additions & 3 deletions packages/kad-dht/src/query-self.ts
Original file line number Diff line number Diff line change
Expand Up @@ -76,7 +76,7 @@ export class QuerySelf implements Startable {
this.timeoutId = setTimeout(() => {
this.querySelf()
.catch(err => {
this.log.error('error running self-query', err)
this.log.error('error running self-query - %e', err)
})
}, this.initialInterval)
}
Expand Down Expand Up @@ -146,7 +146,7 @@ export class QuerySelf implements Startable {
}
}))
} catch (err: any) {
this.log.error('self-query error', err)
this.log.error('self-query error - %e', err)
} finally {
signal.clear()

Expand All @@ -167,7 +167,7 @@ export class QuerySelf implements Startable {
this.timeoutId = setTimeout(() => {
this.querySelf()
.catch(err => {
this.log.error('error running self-query', err)
this.log.error('error running self-query - %e', err)
})
}, this.interval)
}
Expand Down
2 changes: 1 addition & 1 deletion packages/kad-dht/src/query/manager.ts
Original file line number Diff line number Diff line change
Expand Up @@ -217,7 +217,7 @@ export class QueryManager implements Startable {
// Execute the query along each disjoint path and yield their results as they become available
for await (const event of merge(...paths)) {
if (event.name === 'QUERY_ERROR') {
log.error('query error', event.error)
log.error('query error - %e', event.error)
}

if (event.name === 'PEER_RESPONSE') {
Expand Down
2 changes: 1 addition & 1 deletion packages/kad-dht/src/reprovider.ts
Original file line number Diff line number Diff line change
Expand Up @@ -152,7 +152,7 @@ export class Reprovider extends TypedEventEmitter<ReprovideEvents> {
})
}
} catch (err: any) {
this.log.error('error processing datastore key %s - %e', entry.key, err.message)
this.log.error('error processing datastore key %s - %s', entry.key, err.message)
}
}

Expand Down
8 changes: 4 additions & 4 deletions packages/kad-dht/src/routing-table/refresh.ts
Original file line number Diff line number Diff line change
Expand Up @@ -107,24 +107,24 @@ export class RoutingTableRefresh {
try {
await this._refreshCommonPrefixLength(n, lastRefresh, force, options)
} catch (err: any) {
this.log.error(err)
this.log.error('failed to refresh entries with common prefix length %d - %e', n, err)
}
}
}
} catch (err: any) {
this.log.error(err)
this.log.error('failed to refresh entries with common prefix length - %e', err)
}
})
).catch(err => {
this.log.error(err)
this.log.error('failed to refresh table - %e', err)
}).then(() => {
this.refreshTimeoutId = setTimeout(this.refreshTable, this.refreshInterval)

if (this.refreshTimeoutId.unref != null) {
this.refreshTimeoutId.unref()
}
}).catch(err => {
this.log.error(err)
this.log.error('failed to set refresh timeout - %e', err)
})
}

Expand Down
6 changes: 2 additions & 4 deletions packages/kad-dht/src/rpc/handlers/put-value.ts
Original file line number Diff line number Diff line change
Expand Up @@ -39,10 +39,8 @@ export class PutValueHandler implements DHTMessageHandler {
this.log('%p asked us to store value for key %b', peerId, key)

if (msg.record == null) {
const errMsg = `Empty record from: ${peerId.toString()}`

this.log.error(errMsg)
throw new InvalidMessageError(errMsg)
this.log.error('empty record from %p', peerId)
throw new InvalidMessageError(`Empty record from: ${peerId}`)
}

try {
Expand Down
2 changes: 1 addition & 1 deletion packages/keychain/src/keychain.ts
Original file line number Diff line number Diff line change
Expand Up @@ -175,7 +175,7 @@ export class Keychain implements KeychainInterface {
return JSON.parse(uint8ArrayToString(res))
} catch (err: any) {
await randomDelay()
this.log.error(err)
this.log.error('could not read key from datastore - %e', err)
throw new NotFoundError(`Key '${name}' does not exist.`)
}
}
Expand Down
4 changes: 2 additions & 2 deletions packages/libp2p-daemon-client/src/index.ts
Original file line number Diff line number Diff line change
Expand Up @@ -256,11 +256,11 @@ class Client implements DaemonClient {
.finally(() => {
connection.close()
.catch(err => {
log.error(err)
log.error('error closing connection - %e', err)
})
listener.close()
.catch(err => {
log.error(err)
log.error('error closing listener - %e', err)
})
})
}
Expand Down
8 changes: 4 additions & 4 deletions packages/libp2p-daemon-server/src/dht.ts
Original file line number Diff line number Diff line change
Expand Up @@ -30,7 +30,7 @@ export class DHTOperations {
await drain(this.dht.provide(cid))
yield OkResponse()
} catch (err: any) {
log.error(err)
log.error('failed to provide CID %s - %e', cid, err)
yield ErrorResponse(err)
}
}
Expand Down Expand Up @@ -73,7 +73,7 @@ export class DHTOperations {
}
}
} catch (err: any) {
log.error(err)
log.error('error getting value for key %b - %e', key, err)
yield ErrorResponse(err)
}
}
Expand All @@ -84,7 +84,7 @@ export class DHTOperations {

yield OkResponse()
} catch (err: any) {
log.error(err)
log.error('error putting value %b for key %b - %e', value, key, err)
yield ErrorResponse(err)
}
}
Expand All @@ -107,7 +107,7 @@ export class DHTOperations {

throw new Error('Peer not found')
} catch (err: any) {
log.error(err)
log.error('peer not found %p - %e', peerId, err)
yield ErrorResponse(err)
}
}
Expand Down
14 changes: 7 additions & 7 deletions packages/libp2p-daemon-server/src/index.ts
Original file line number Diff line number Diff line change
Expand Up @@ -179,7 +179,7 @@ export class Server implements Libp2pServer {
stream
)
} catch (err: any) {
log.error(err)
log.error('error handling stream handler - %e', err)

conn?.abort(err)
} finally {
Expand All @@ -206,7 +206,7 @@ export class Server implements Libp2pServer {

_onExit (): void {
void this.stop({ exit: true }).catch(err => {
log.error(err)
log.error('failed to stop daemon during exit - %e', err)
})
}

Expand Down Expand Up @@ -262,7 +262,7 @@ export class Server implements Libp2pServer {
throw new Error('ERR_INVALID_REQUEST_TYPE')
}
} catch (err: any) {
log.error(err)
log.error('error handling peerstore request - %e', err)
yield ErrorResponse(err)
}
}
Expand Down Expand Up @@ -305,7 +305,7 @@ export class Server implements Libp2pServer {
throw new Error('ERR_INVALID_REQUEST_TYPE')
}
} catch (err: any) {
log.error(err)
log.error('error handling pubsub request - %e', err)
yield ErrorResponse(err)
}
}
Expand Down Expand Up @@ -373,7 +373,7 @@ export class Server implements Libp2pServer {
throw new Error('ERR_INVALID_REQUEST_TYPE')
}
} catch (err: any) {
log.error(err)
log.error('error handling DHT request - %e', err)
yield ErrorResponse(err)
}
}
Expand Down Expand Up @@ -521,7 +521,7 @@ export class Server implements Libp2pServer {
throw new Error('ERR_INVALID_REQUEST_TYPE')
}
} catch (err: any) {
log.error(err)
log.error('error handling incoming connection - %e', err)

// recreate pb stream in case the original was unwrapped already
const conn = pb.unwrap()
Expand All @@ -547,7 +547,7 @@ export class Server implements Libp2pServer {
}
})
.catch(err => {
log.error('error handling incoming connection', err)
log.error('error handling incoming connection - %e', err)
})
}
}
Expand Down
8 changes: 4 additions & 4 deletions packages/libp2p-daemon-server/src/pubsub.ts
Original file line number Diff line number Diff line change
Expand Up @@ -34,7 +34,7 @@ export class PubSubOperations {
}
})
} catch (err: any) {
log.error(err)
log.error('failed to get pubsub topics - %e', err)
yield ErrorResponse(err)
}
}
Expand Down Expand Up @@ -71,7 +71,7 @@ export class PubSubOperations {
yield OkResponse()
yield * onMessage
} catch (err: any) {
log.error(err)
log.error('failed to subscribe to topic %s - %e', topic, err)
yield ErrorResponse(err)
}
}
Expand All @@ -81,7 +81,7 @@ export class PubSubOperations {
await this.pubsub.publish(topic, data)
yield OkResponse()
} catch (err: any) {
log.error(err)
log.error('failed to publish message to topic %s - %e', topic, err)
yield ErrorResponse(err)
}
}
Expand All @@ -95,7 +95,7 @@ export class PubSubOperations {
}
})
} catch (err: any) {
log.error(err)
log.error('failed to list peers for topic %s - %e', topic, err)
yield ErrorResponse(err)
}
}
Expand Down
2 changes: 1 addition & 1 deletion packages/libp2p/src/address-manager/index.ts
Original file line number Diff line number Diff line change
Expand Up @@ -186,7 +186,7 @@ export class AddressManager implements AddressManagerInterface {
multiaddrs: addrs
})
.catch(err => {
this.log.error('error updating addresses', err)
this.log.error('error updating addresses - %e', err)
})
}

Expand Down
Loading
Loading