Skip to content
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

How to check if client cancelled / deadline exceeded #1591

Open
t089 opened this issue Apr 19, 2023 · 2 comments
Open

How to check if client cancelled / deadline exceeded #1591

t089 opened this issue Apr 19, 2023 · 2 comments
Labels

Comments

@t089
Copy link

t089 commented Apr 19, 2023

From the gRPC docs:

On the server side, the server can query to see if a particular RPC is no longer wanted. Before a server starts work on a response it is very important to check if there is still a client waiting for it. This is especially important to do before starting expensive processing.

How can I check in Swift on the server side, if the client cancelled the request or the client provided deadline exceeded? The GRPCAsyncServerCallContext does not seem to give much info on this.

Related, is the deadline passed to the server so that I can use it as a deadline for other dependent calls?

@t089 t089 added the question label Apr 19, 2023
@glbrntt
Copy link
Collaborator

glbrntt commented Apr 19, 2023

How can I check in Swift on the server side, if the client cancelled the request...

If the client cancels then the stream will be closed and the Task executing the server handler will be cancelled.

...or the client provided deadline exceeded? The GRPCAsyncServerCallContext does not seem to give much info on this.

We don't currently monitor this on the server side; if the client set a timeout the 'grpc-timeout' header will be set, so it should be possible to parse that into a timeout which in turn can be made into a deadline. We don't currently have code to do that but it shouldn't be too difficult to do.

@t089
Copy link
Author

t089 commented Apr 20, 2023

That sound's great, thank you!

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
Projects
None yet
Development

No branches or pull requests

2 participants