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)
|
||||
|
||||
# read frames until closed
|
||||
try:
|
||||
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:
|
||||
trace "Exception closing", exc = exc.msg
|
||||
|
|
Loading…
Reference in New Issue