-
-
Notifications
You must be signed in to change notification settings - Fork 390
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
SendStream::finish()
no longer errors when connection is closed
#1926
Comments
Thanks for the report! I believe this was intended. In particular, the current behavior is described accurately by the rustdoc:
The reasoning here was that it's common for peers to routinely I appreciate that it's counterintuitive that calling I'm interested in feedback about how much sense this makes to you, and where we could improve in documentation or API to make things more obvious or convenient. You can reconstruct the previous behavior by waiting on |
I guess it is reasonable to not give an error, after all the peer already knows no more data will be written on the stream if it is closed and as you say stops and finishes may be crossing on the wire anyway. I think the docs can be a little better though. Right now I'm not sure how to interpret that error and wonder if calling My attempt at rewriting the docs right now would look something like:
|
there seems to be another behavioural change. calling finish used to wait for the data to be transfered. now on an unidirectional stream, this causes an incoming substream which immediately returns an error. this doesn't seem to be the case for bidirectional streams. async fn send_request<P: Protocol>(tx: &mut SendStream, req: &P::Request) -> Result<()> {
tx.write_u16(P::ID).await?;
let bytes = bincode::serialize(req)?;
tx.write_all(&bytes).await?;
tx.finish()?;
Ok(())
} let uni = conn2.accept_uni().await;
let rx = match uni {
Ok(rx) => rx,
Err(_) => {
// Err(ApplicationClosed(ApplicationClose { error_code: 0, reason: b"" }))
break;
}
}; |
Sorry, I don't understand what you're trying to communicate here.
This error means that the peer application has closed the connection. If you don't want that to happen, don't do that. |
Finish used to mean I'm done sending more data, not close the connection and drop the buffers |
How can I get the previous behavior? |
|
so the equivalent of |
In Quinn 0.10
SendStream::finish()
used to return an error if the connection was already closed. Now it still returnsOk(())
.Full example code at https://gist.github.com/flub/56450fb16ec7c93998e7feedcb5659a0 but here are the relevant server and client pieces:
The server accepts a uni-directional stream, reads some data so that we know both the server and client have opened the stream successfully. Then it closes the connection with a custom code.
After connecting, creating and writing to the stream the client waits for the stream to be closed by the remote. Now the client tries to call
.finish()
, which I would expect to error. However it returnsOk(())
:Is there a conscious reason this behaviour changed? I was expecting finish to return an error at this point.
The text was updated successfully, but these errors were encountered: