-
Notifications
You must be signed in to change notification settings - Fork 254
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
Client Stream of a streaming server can't be Boxed #123
Comments
That's because channel get dropped early. But it should return error instead of core. |
If the |
Thanks for the suggestion. But channel may become invalid even a reference is kept, which can just ensure it's not dropped by the wrapper. And actually there are two kinds of calls here, client call and server call. For client call, we can get the channel easily, but for server call there is no API to obtain the underlying channel yet. So I think it's better to just return an error to state what's happening. Besides, when We may need to explain the whole mechanism in our documentations. /cc #114 And I believe the coredump should be fixed by #125. |
Then it sounds like the clone of the While it's not a memory safety issue, it's definitely a deviation from the implicit contract of |
This can, on the server side, happen in a wide variety of contexts. Currently, simple calls such as : let answers_client = answers_grpc::AnswersClient::open_with_defaults();
let answers_stream = answers_client
.as_publish_opt(
&AnswersRequest::default(),
call_config(),
)
.expect("Could not get answers"); succeed, while these: let answers_stream = answers_grpc::AnswersClient::open_with_defaults()
.as_publish_opt(
&AnswersRequest::default(),
call_config(),
)
.expect("Could not get answers"); don't, and since no lifetimes are involved, this is a terrible trap. I also feel like Call should hold the Another alternative that avoids the issue with the |
This PR implements the latter by holding the |
Holding The provided example is not a trap if the contract is fully understood. Not all lifetime dependency should be constrained by lifetime. For example, when using a thread pool to spawn a task, no one thinks the task can still succeed after dropping the pool. It's considered a valid case that the future should be resolved as failure.
|
To be honest I'm not sure I would necessarily know there's a problem if I see that tokio example somewhere. ^^' In our case, it's pretty clear that the call can fail if there's a networking issue, is cancelled by the server, etc... which already justifies the presence of Also, In the case of Of course "if the contract is fully understood", well, you know. The point is that we've been several people not understanding this contract at first sight, so maybe we could make it easier to understand - be it by changing it or not. Finally, I don't understand the resource-leak case you are talking about in the first paragraph. |
Users can close the channel for quickly shutdown or whatever suitable. Documentation needs to explain the mechanism clearly as I suggested. |
I've put a repro at https://github.com/illicitonion/grpc-rs-repro-0 which uses the proto from https://github.com/googleapis/googleapis/blob/master/google/bytestream/bytestream.proto
The call to call_sync, which doesn't move the stream out of the function, reliably works.
The call to call_future, which Boxes the stream, either gives me:
or
I believe both should be safe, and it's possible that the Stream being produced by the client isn't properly owning all of the state it needs.
The text was updated successfully, but these errors were encountered: