Skip to content

Fix TensorzeroHttpClient behavior for streaming requests#3773

Merged
Aaron1011 merged 2 commits intomainfrom
aaron/streaming-limited-client
Oct 1, 2025
Merged

Fix TensorzeroHttpClient behavior for streaming requests#3773
Aaron1011 merged 2 commits intomainfrom
aaron/streaming-limited-client

Conversation

@Aaron1011
Copy link
Copy Markdown
Member

@Aaron1011 Aaron1011 commented Oct 1, 2025

We were double-decrementing the counter when constructing a TensorZeroEventSource, which could lead to the counter underflowing to the maximum value.

We now avoid decrementing the counter when we drop the original 'LimitedClientTicket', and test a mixture of streaming and non-streaming requests


Important

Fix double-decrement issue in TensorzeroHttpClient by adjusting LimitedClientTicket logic and add tests for streaming and non-streaming requests.

  • Behavior:
    • Fix double-decrement issue in LimitedClientTicket by introducing should_decrement flag to control counter decrement.
    • Adjust into_owned() in LimitedClientTicket to set should_decrement to false when ownership is transferred.
  • Tests:
    • Add tests in tests module to verify correct behavior for streaming and non-streaming requests.
    • Ensure tests cover scenarios with mixed request types and validate client initialization and request handling.
  • Misc:
    • Update TensorzeroRequestBuilder to use into_owned() for eventsource() method.

This description was created by Ellipsis for 734662f. You can customize this summary. It will automatically update as commits are pushed.

We were double-decrementing the counter when constructing a
`TensorZeroEventSource`, which could lead to the counter
underflowing to the maximum value.

We now avoid decrementing the counter when we drop the original
'LimitedClientTicket', and test a mixture of streaming
and non-streaming requests
Copilot AI review requested due to automatic review settings October 1, 2025 15:23
Copy link
Copy Markdown
Contributor

Copilot AI left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Pull Request Overview

This PR fixes a double-decrement bug in the HTTP client's concurrency counter when handling streaming requests. The issue occurred when creating a TensorZeroEventSource from a LimitedClientTicket, which would cause the counter to be decremented twice and potentially underflow.

  • Adds a should_decrement flag to LimitedClientTicket to control when the counter is decremented
  • Introduces into_owned() method to transfer ownership without double-decrementing
  • Adds comprehensive tests for both streaming and non-streaming requests to verify correct counter behavior

Tip: Customize your code reviews with copilot-instructions.md. Create the file or learn how to get started.

@virajmehta virajmehta self-assigned this Oct 1, 2025
@virajmehta virajmehta enabled auto-merge October 1, 2025 15:33
@virajmehta virajmehta assigned Aaron1011 and unassigned virajmehta Oct 1, 2025
@virajmehta virajmehta added this pull request to the merge queue Oct 1, 2025
@github-merge-queue github-merge-queue bot removed this pull request from the merge queue due to failed status checks Oct 1, 2025
@Aaron1011 Aaron1011 added this pull request to the merge queue Oct 1, 2025
github-merge-queue bot pushed a commit that referenced this pull request Oct 1, 2025
* Fix TensorzeroHttpClient behavior for streaming requests

We were double-decrementing the counter when constructing a
`TensorZeroEventSource`, which could lead to the counter
underflowing to the maximum value.

We now avoid decrementing the counter when we drop the original
'LimitedClientTicket', and test a mixture of streaming
and non-streaming requests

* Fix clippy and add comments
@github-merge-queue github-merge-queue bot removed this pull request from the merge queue due to failed status checks Oct 1, 2025
@Aaron1011 Aaron1011 added this pull request to the merge queue Oct 1, 2025
Merged via the queue into main with commit f422148 Oct 1, 2025
29 of 30 checks passed
@Aaron1011 Aaron1011 deleted the aaron/streaming-limited-client branch October 1, 2025 19:43
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

3 participants