diff --git a/libp2p/stream/chronosstream.nim b/libp2p/stream/chronosstream.nim index 968e021..0f9a125 100644 --- a/libp2p/stream/chronosstream.nim +++ b/libp2p/stream/chronosstream.nim @@ -55,10 +55,14 @@ method write*(s: ChronosStream, msg: seq[byte], msglen = -1) {.async, gcsafe.} = await s.writer.write(msg, msglen) method close*(s: ChronosStream) {.async, gcsafe.} = - await s.reader.closeWait() + if not s.closed: + if not s.reader.closed: + await s.reader.closeWait() - await s.writer.finish() - await s.writer.closeWait() + await s.writer.finish() - await s.client.closeWait() - s.closed = true \ No newline at end of file + if not s.writer.closed: + await s.writer.closeWait() + + await s.client.closeWait() + s.closed = true \ No newline at end of file