diff --git a/packages/libp2p-daemon-protocol/src/stream-handler.ts b/packages/libp2p-daemon-protocol/src/stream-handler.ts index 45546445..76b2d2c8 100644 --- a/packages/libp2p-daemon-protocol/src/stream-handler.ts +++ b/packages/libp2p-daemon-protocol/src/stream-handler.ts @@ -27,16 +27,12 @@ export class StreamHandler { /** * Read and decode message */ - async read (): Promise { - // @ts-expect-error decoder is really a generator - const msg = await this.decoder.next() - if (msg.value != null) { - return msg.value.subarray() + async read (): Promise { + try { + return await this.lp.read() + } catch (err) { + log.error('read received no value', err) } - - log('read received no value, closing stream') - // End the stream, we didn't get data - await this.close() } async write (msg: Uint8Array | Uint8ArrayList): Promise {