summary refs log tree commit diff stats
diff options
context:
space:
mode:
-rw-r--r--lib/pure/asyncio.nim7
1 files changed, 5 insertions, 2 deletions
diff --git a/lib/pure/asyncio.nim b/lib/pure/asyncio.nim
index c4a07d751..3c2a5c17a 100644
--- a/lib/pure/asyncio.nim
+++ b/lib/pure/asyncio.nim
@@ -233,8 +233,11 @@ proc asyncSockHandleWrite(h: PObject) =
       let sock = PAsyncSocket(h)
       try:
         let bytesSent = sock.socket.sendAsync(sock.sendBuffer)
-        assert bytesSent > 0
-        if bytesSent != sock.sendBuffer.len:
+        if bytesSent == 0:
+          # Apparently the socket cannot be written to. Even though select
+          # just told us that it can be... This used to be an assert. Just
+          # do nothing instead.
+        elif bytesSent != sock.sendBuffer.len:
           sock.sendBuffer = sock.sendBuffer[bytesSent .. -1]
         elif bytesSent == sock.sendBuffer.len:
           sock.sendBuffer = ""