There are two edge cases that currently trigger KeyError:
await newStream.open() succeeds, but Chronos injects an implicit suspend point when an {.async.} function that suspended returns. During this implicit suspend point, another task could get scheduled and close the stream, which removes it from m.channels again. let channel = m.channels[header.streamId then gives KeyError. More explanation of implicit suspend point on return after await: https://github.com/status-im/nim-chronos/pull/273
During the Flush the data block, await m.connection.readExactly is called which may suspend. If it suspends, same as above, another task may get scheduled that closes the stream, also resulting in the KeyError below.
The YamuxError is subsequently properly handled below.
There are two edge cases that currently trigger
KeyError
:await newStream.open()
succeeds, but Chronos injects an implicit suspend point when an{.async.}
function that suspended returns. During this implicit suspend point, another task could get scheduled and close the stream, which removes it fromm.channels
again.let channel = m.channels[header.streamId
then givesKeyError
. More explanation of implicit suspend point on return after await: https://github.com/status-im/nim-chronos/pull/273During the
Flush the data
block,await m.connection.readExactly
is called which may suspend. If it suspends, same as above, another task may get scheduled that closes the stream, also resulting in theKeyError
below.The
YamuxError
is subsequently properly handled below.