Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
avoid
KeyError
in edge case of yamux handler
There are two edge cases that currently trigger `KeyError`: 1. `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: status-im/nim-chronos#273 2. 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.
- Loading branch information