diff --git a/.changeset/lovely-hats-join.md b/.changeset/lovely-hats-join.md new file mode 100644 index 0000000..4f77d51 --- /dev/null +++ b/.changeset/lovely-hats-join.md @@ -0,0 +1,5 @@ +--- +'@rosen-bridge/rosenet-node': patch +--- + +Fix issue of RoseNet direction protocol listener pipe not getting awaited diff --git a/packages/rosenet-node/lib/rosenet-direct/handleIncomingMessage.ts b/packages/rosenet-node/lib/rosenet-direct/handleIncomingMessage.ts index e756e7b..7159d27 100644 --- a/packages/rosenet-node/lib/rosenet-direct/handleIncomingMessage.ts +++ b/packages/rosenet-node/lib/rosenet-direct/handleIncomingMessage.ts @@ -23,23 +23,32 @@ const handleIncomingMessageFactory = transient: connection.transient, }, ); - pipe( - stream, - decode, - async function* (source) { - for await (const message of source) { - RoseNetNodeContext.logger.debug( - 'message received, calling handler and sending ack', - { - message, - }, - ); - handler(connection.remotePeer.toString(), message); - yield Uint8Array.of(ACK_BYTE); - } - }, - stream, - ); + try { + await pipe( + stream, + decode, + async function* (source) { + for await (const message of source) { + RoseNetNodeContext.logger.debug( + 'message received, calling handler and sending ack', + { + message, + }, + ); + handler(connection.remotePeer.toString(), message); + yield Uint8Array.of(ACK_BYTE); + } + }, + stream, + ); + } catch (error) { + RoseNetNodeContext.logger.warn( + 'An error occurred while reading from stream', + { + error, + }, + ); + } }, { runOnTransientConnection: true }, );