-
Notifications
You must be signed in to change notification settings - Fork 561
fix: bound streamable HTTP memory usage #970
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
Merged
Merged
Changes from all commits
Commits
File filter
Filter by extension
Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
There are no files selected for viewing
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Oops, something went wrong.
Add this suggestion to a batch that can be applied as a single commit.
This suggestion is invalid because no changes were made to the code.
Suggestions cannot be applied while the pull request is closed.
Suggestions cannot be applied while viewing a subset of changes.
Only one suggestion per line can be applied in a batch.
Add this suggestion to a batch that can be applied as a single commit.
Applying suggestions on deleted lines is not supported.
You must change the existing code in this line in order to create a valid suggestion.
Outdated suggestions cannot be applied.
This suggestion has been applied or marked resolved.
Suggestions cannot be applied from pending reviews.
Suggestions cannot be applied on multi-line comments.
Suggestions cannot be applied while the pull request is queued to merge.
Suggestion cannot be applied right now. Please check back later.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
My only Q would be whether we can apply the new defaults at the HTTP client level for all requests, instead of providing these methods for per request type limit setting. If not, feel free to go ahead as-is.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
@alexhancock The value here is actually a single client-wide setting that gets threaded through each call. I see the method signature make it look like a per-request-type limit. I'll add some comment to clear that up.
Uh oh!
There was an error while loading. Please reload this page.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
My question was more why we needed the new wrapper methods, and why the limit couldn't be applied internally in
self.http_client.get_stream_with_max_sse_event_sizefor exampleJust not yet understanding
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
@alexhancock The limit isn't stored on the client, so there's nothing for
AuthClientto read internally. It lives on the transport config, and the clients are separate objects passed intowith_client(client, config). One of them isreqwest::Client, which is a foreign type we can't add a field to, so the value has to come from the worker at call time.Also,
AuthClientisn't where the bounding can happen. The cap is applied at the raw byte layer, whereresponse.bytes_stream()gets wrapped into anSseStream. That only happens in the leaf client (reqwest or unix socket).AuthClientjust adds the auth token and forwards to the inner client, so all it can do is passmax_sse_event_sizealong.So the value flows from the worker, through
AuthClient, down to the client that actually reads the bytes. Dropping the parameter would mean storing the limit on the client, but because it's implemented on the foreignreqwest::Clientthat needs a wrapper type and removing the bare impl. I'd rather keep that as a separate follow-up.