From 2c67c595f82cc9ec5f3042a77e40b9bd6b77b746 Mon Sep 17 00:00:00 2001 From: RadKesvat <> Date: Wed, 28 Jun 2023 18:05:40 +0430 Subject: [PATCH] prevent crash on pending connection when closing socket --- src/overrides/asyncnet.nim | 5 +++++ 1 file changed, 5 insertions(+) diff --git a/src/overrides/asyncnet.nim b/src/overrides/asyncnet.nim index 6e3d0b1..f38457b 100644 --- a/src/overrides/asyncnet.nim +++ b/src/overrides/asyncnet.nim @@ -308,6 +308,11 @@ proc connect*(socket: AsyncSocket, address: string, port: Port, sni:string = "") ## Returns a `Future` which will complete when the connection succeeds ## or an error occurs. await connect(socket.fd.AsyncFD, address, port, socket.domain) + if socket.closed: + raise newException(EOFError, + "Socket is closed before full connection establishment") + + if socket.isSsl: when defineSsl: if sni != "":