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

Client does not respect context canceled #1698

Open
ameyaach opened this issue Dec 12, 2024 · 1 comment
Open

Client does not respect context canceled #1698

ameyaach opened this issue Dec 12, 2024 · 1 comment
Labels

Comments

@ameyaach
Copy link

The client does not respect timeouts set on the context. We set a context timeout of 5s and the call blocked for 3 minutes.

Following the code, we realized that the client will always block on the done channel being closed (see here). The client waits for all data to be streamed regardless of whether the context is canceled or timed out. Once the context deadline has passed, there is no point in blocking because the underlying function (QueryRange) ultimately returns an error when the context is canceled, so we blocked for an additional 2min 55seconds when we knew that after 5s QueryRange would return an error.

SHA: dcf944d

Copy link

dosubot bot commented Dec 12, 2024

Hey @ameyaach! I'm here to help you with any bugs, questions, or contributions you have. Let's tackle this issue together!

The issue you're encountering seems to be related to how the client handles context cancellations and timeouts. The done channel in the client.go file is used to signal the completion of reading the response body in a separate goroutine. The main goroutine waits for this channel to close, which can lead to blocking even after the context is canceled or times out [1].

In the current implementation, the client waits for the response body to be fully read before proceeding, regardless of the context's state. This behavior can indeed cause the client to block longer than expected if the context is canceled or times out.

To address this, you might consider modifying the logic to immediately handle context cancellations by closing the response body and returning an error as soon as the context is done, rather than waiting for the done channel. This would prevent the additional blocking time after the context deadline has passed.

To continue talking to Dosu, mention @dosu.


Help Dosu learn! Give it feedback: Great Response | Irrelevant Answer | Incorrect Sources | Too Verbose | Hallucination | Other

@dosubot dosubot bot added the bug label Dec 12, 2024
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

1 participant