Skip to content

Can ClientCall.Listener.onClose() ever run after asyncUnaryCall completes. #12234

Closed Answered by AgraVator
catchpolecanva asked this question in Q&A
Discussion options

You must be logged in to vote

No, the ListenableFuture returned by an asyncUnaryCall will not complete before the ClientCall.Listener.onClose() method is invoked.

The completion of the future is fundamentally tied to the gRPC call's lifecycle, which terminates with the onClose event. Your experiment with sleep in onClose correctly demonstrates this: onClose is on the critical path for the call's completion. The future's result (or exception) is set only after the listener has been notified of the call's closure.

Your metrics are not necessarily inaccurate, but they are likely revealing a delay in a different place than you suspect.

What's Likely Happening?
The discrepancy you're observing—where the caller gets the res…

Replies: 2 comments 1 reply

Comment options

You must be logged in to vote
0 replies
Answer selected by catchpolecanva
Comment options

You must be logged in to vote
1 reply
@AgraVator
Comment options

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Category
Q&A
Labels
None yet
2 participants