mirror of https://github.com/vacp2p/nim-libp2p.git
avoid `KeyError` in edge case of yamux handler (#1044)
This commit is contained in:
parent
ee264fdf11
commit
18e00a741b
|
@ -528,7 +528,12 @@ method handle*(m: Yamux) {.async.} =
|
||||||
await m.connection.readExactly(addr buffer[0], int(header.length))
|
await m.connection.readExactly(addr buffer[0], int(header.length))
|
||||||
continue
|
continue
|
||||||
|
|
||||||
let channel = m.channels[header.streamId]
|
let channel =
|
||||||
|
try:
|
||||||
|
m.channels[header.streamId]
|
||||||
|
except KeyError:
|
||||||
|
raise newException(YamuxError,
|
||||||
|
"Stream was cleaned up before handling data: " & $header.streamId)
|
||||||
|
|
||||||
if header.msgType == WindowUpdate:
|
if header.msgType == WindowUpdate:
|
||||||
channel.sendWindow += int(header.length)
|
channel.sendWindow += int(header.length)
|
||||||
|
|
Loading…
Reference in New Issue