mirror of
https://github.com/codex-storage/nim-websock.git
synced 2025-02-13 02:46:31 +00:00
Fix: handle simultaneous closing properly (#112)
Since we use readFrame instead of readMsg, we need to handle it's possible exceptions. Closes #111
This commit is contained in:
parent
8927db93f6
commit
47b486b52f
@ -454,7 +454,11 @@ proc close*(
|
|||||||
opcode = Opcode.Close)
|
opcode = Opcode.Close)
|
||||||
|
|
||||||
# read frames until closed
|
# read frames until closed
|
||||||
while ws.readyState != ReadyState.Closed:
|
try:
|
||||||
discard await ws.readFrame()
|
while ws.readyState != ReadyState.Closed:
|
||||||
|
discard await ws.readFrame()
|
||||||
|
except CatchableError as exc:
|
||||||
|
ws.readyState = ReadyState.Closed
|
||||||
|
await ws.stream.closeWait()
|
||||||
except CatchableError as exc:
|
except CatchableError as exc:
|
||||||
trace "Exception closing", exc = exc.msg
|
trace "Exception closing", exc = exc.msg
|
||||||
|
Loading…
x
Reference in New Issue
Block a user