From 98117a30682ac62bf10bb47f02fec5e5f8b5dbbb Mon Sep 17 00:00:00 2001 From: Dmitriy Ryajov Date: Mon, 11 May 2020 11:36:40 -0600 Subject: [PATCH] call write until all is written out --- libp2p/stream/chronosstream.nim | 6 +++--- 1 file changed, 3 insertions(+), 3 deletions(-) diff --git a/libp2p/stream/chronosstream.nim b/libp2p/stream/chronosstream.nim index c1bca76..b3af6b6 100644 --- a/libp2p/stream/chronosstream.nim +++ b/libp2p/stream/chronosstream.nim @@ -60,9 +60,9 @@ method write*(s: ChronosStream, msg: seq[byte]) {.async.} = return withExceptions: - # Returns 0 sometimes when write fails - but there's not much we can do here? - if (await s.client.write(msg)) != msg.len: - raise (ref LPStreamError)(msg: "Write couldn't finish writing") + var writen = 0 + while (writen < msg.len): + writen += await s.client.write(msg[writen..