Skip to content
This repository was archived by the owner on Jul 10, 2025. It is now read-only.
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
28 changes: 17 additions & 11 deletions packages/core/js-client/src/connection/RelayConnection.ts
Original file line number Diff line number Diff line change
Expand Up @@ -18,7 +18,7 @@ import { noise } from "@chainsafe/libp2p-noise";
import { yamux } from "@chainsafe/libp2p-yamux";
import { PeerIdB58 } from "@fluencelabs/interfaces";
import { identify } from "@libp2p/identify";
import type { PeerId, Stream } from "@libp2p/interface";
import type { PeerId } from "@libp2p/interface";
import { peerIdFromString } from "@libp2p/peer-id";
import { ping } from "@libp2p/ping";
import { webSockets } from "@libp2p/websockets";
Expand Down Expand Up @@ -180,33 +180,39 @@ export class RelayConnection implements IConnection {
);
}

log.trace("sending particle...");

// Reusing active connection here
const stream = await this.lib2p2Peer.dialProtocol(
this.relayAddress,
PROTOCOL_NAME,
);

log.trace("created stream with id ", stream.id);
log.trace(
"sending particle %s to %s",
particle.id,
this.relayAddress.toString(),
);

const sink = stream.sink;

await pipe([fromString(serializeToString(particle))], encode, sink);
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

is there never an error here? 🤔 Or is there a log for particle sending error in a separate place?

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Yes, particle log for network error resides in calling class - FluencePeer

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

log.trace("data written to sink");

log.trace(
"particle %s sent to %s",
particle.id,
this.relayAddress.toString(),
);
}

// Await will appear after uncommenting lines in func body
// eslint-disable-next-line @typescript-eslint/require-await
private async processIncomingMessage(msg: string, stream: Stream) {
private async processIncomingMessage(msg: string) {
let particle: Particle | undefined;

try {
particle = Particle.fromString(msg);

log.trace(
"got particle from stream with id %s and particle id %s",
stream.id,
"received particle %s from %s",
particle.id,
this.relayAddress.toString(),
);

const initPeerId = peerIdFromString(particle.initPeerId);
Expand Down Expand Up @@ -268,7 +274,7 @@ export class RelayConnection implements IConnection {
async (source) => {
try {
for await (const msg of source) {
await this.processIncomingMessage(msg, stream);
await this.processIncomingMessage(msg);
}
} catch (e) {
log.error("connection closed: %j", e);
Expand Down
7 changes: 6 additions & 1 deletion packages/core/js-client/src/jsPeer/FluencePeer.ts
Original file line number Diff line number Diff line change
Expand Up @@ -424,8 +424,13 @@ export abstract class FluencePeer {
): Promise<CallServiceResult> {
const particleId = req.particleContext.particleId;

log_particle.debug("id %s. executing call service handler %j", particleId, {
serviceId: req.serviceId,
functionName: req.fnName,
});

log_particle.trace(
"id %s. executing call service handler %j",
"id %s. executing call service handler detailed %j",
particleId,
req,
);
Expand Down
12 changes: 0 additions & 12 deletions packages/core/js-client/src/util/logger.ts
Original file line number Diff line number Diff line change
Expand Up @@ -50,15 +50,3 @@ export function marineLogger(serviceId: string): MarineLogger {
info: debug(`${name}:info`),
};
}

export function disable() {
debug.disable();
}

export function enable(namespaces: string) {
debug.enable(namespaces);
}

export function enabled(namespaces: string) {
return debug.enabled(namespaces);
}