Open Saigut opened 2 years ago
I would say that it is more like the stream acceptance callback is called too late. I got the same issue during bitswap message receiving from a remote go-ipfs peer. The go-ipfs peers sends 3 frames:
Detailed investigation has shown that YamuxStream::doRead returns corresponding error https://github.com/libp2p/cpp-libp2p/blob/91d58f28bb8cbce06fd717082fa2b4274a33ae07/src/muxer/yamux/yamux_stream.cpp#L447 only when no pending data is available in the internal_readbuffer. https://github.com/libp2p/cpp-libp2p/blob/91d58f28bb8cbce06fd717082fa2b4274a33ae07/src/muxer/yamux/yamux_stream.cpp#L425 I'm not sure what is a semantics of YamuxStream::isClosedForRead method but it looks like the size of pending data should be checked within the method also.
From testing of my program, after YamuxStream tagging stream being unreadable in onFINReceived at this line, there may still be remaining data to be processed in onLengthRead. So I think tagging stream being unreadable in onFINReceived is too early.
I have no better idea for now, so I just comment this line to workaround this issue.