mirror of
https://github.com/logos-storage/nim-websock.git
synced 2026-01-03 14:13:11 +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)
|
||||
|
||||
# read frames until closed
|
||||
while ws.readyState != ReadyState.Closed:
|
||||
discard await ws.readFrame()
|
||||
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…
x
Reference in New Issue
Block a user