You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
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.
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.
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
The text was updated successfully, but these errors were encountered: