From d01393774ececa7a0b88769701db3d19778664e8 Mon Sep 17 00:00:00 2001 From: Tanguy Date: Wed, 10 May 2023 17:37:24 +0200 Subject: [PATCH] also in handleClose --- websock/session.nim | 10 ++++++++++ 1 file changed, 10 insertions(+) diff --git a/websock/session.nim b/websock/session.nim index 5225db45..472e699d 100644 --- a/websock/session.nim +++ b/websock/session.nim @@ -264,6 +264,16 @@ proc handleClose*( await sleepAsync(10.millis) await ws.stream.closeWait() + if not isNil(ws.sendLoop): + ws.sendLoop.cancel() + # don't care about opcode, + # but we can only have a single + # `_` in 1.2 + for (_, opcode, fut) in ws.sendQueue: + if not fut.finished: + fut.fail(WSClosedError.newException("Session got closed")) + ws.sendQueue.clear() + proc handleControl*(ws: WSSession, frame: Frame) {.async.} = ## Handle control frames ##