-
Notifications
You must be signed in to change notification settings - Fork 0
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Streams recreate themselves after ending #24
Comments
i think this is because of a race condition in how streams are created. The opening of stream happens when an ACK message is received. So if the peer sends an ACK after a stream has been closed locally, the stream will be re-opened |
Possible fixes could be
|
This actually occurred before in js-quic. We also get a concurrent message that triggered the re-opening of the stream. I forgot how we dealt with this? But @tegefaulkes has more details here. |
This is happening during a graceful close. Nothing concurrent is happening or weird should be causing this. What happened in |
One of the ways we dealt with this is to have Then when we process a stream event... we always create streams whether a stream is readable or writable, and if the stream already exists, then we run the So if you look at |
It can still be concurrent on the network if the reason the stream is being recreated is because the peer's sent ACK is only received after the stream is already destroyed. Point is, we need some sort of condition that simply says that once a stream is closed/destroyed, it should never lead it being recreated in any form. If that requires keeping track of the peer stream ID counter, so be it. Although that seems similar to MatrixAI/js-quic#66 |
The tempfix above isn't really efficient, stream IDs always are linearly incremented, so it's sufficient to simply keep a counter as the threshold. |
For js-quic, we are prompting quiche to shutdown the underlying quiche state. And we're trying to maintain consistency between For js-ws, there is no underlying library for our streams. All state is just in the JS side (that we invented and have full control over). Therefore if there's a pending ACK that may end up recreating a stream, the solution is to ensure that you just ignore such packets if the stream ID counter is already gone past that point. At some point you have to think about protocol robustness. What if the peer is improperly implemented? What if they send you stream frames with stream IDs that aren't supposed to occur, or they try to re-use stream IDs. I believe in QUIC, you're supposed to consider these as connection protocol errors and simply close the connection. You could do the same in WS. However if it is natural for the ack to be delayed in processing, you probably don't want to close the whole connection because of this. Therefore the connection lifecycle should be able to gracefully deal with this delayed processing of the ACK. |
This is fixed isn't it? Or is it still a temp fix? I'll have to double check… |
Did you check this? @tegefaulkes |
I haven't checked this yet. |
Specification
After a stream has ended it seems to re-create itself with the same
streamId
and get's emitted as a new stream event. This is after creating a single stream and ending it gracefully.Here is a reproducible example.
I have already applied a quick fix to this in the
WebSocketConnection
with the following.But this is far from ideal, The whole problem needs to be investigated and have a proper fix applied for it.
Additional context
ClientService
and js-ws and js-rpc integration Polykey#560Tasks
The text was updated successfully, but these errors were encountered: