-
Notifications
You must be signed in to change notification settings - Fork 3k
fix: add explicit timeout to OpenAPI tool httpx client #4432
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
base: main
Are you sure you want to change the base?
Changes from 1 commit
69d0179
d6546d8
d12bdc2
c02e275
1e9537a
faacc4f
5889a56
67eca33
030f6b9
File filter
Filter by extension
Conversations
Jump to
Diff view
Diff view
There are no files selected for viewing
| Original file line number | Diff line number | Diff line change | ||||
|---|---|---|---|---|---|---|
|
|
@@ -560,6 +560,7 @@ def __repr__(self): | |||||
|
|
||||||
| async def _request(**request_params) -> httpx.Response: | ||||||
| async with httpx.AsyncClient( | ||||||
| verify=request_params.pop("verify", True) | ||||||
| verify=request_params.pop("verify", True), | ||||||
| timeout=None, | ||||||
|
||||||
| timeout=None, | |
| timeout=request_params.pop("timeout", None), |
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.
can you please address this.
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.
I've updated the implementation based on the feedback:
- Changed to
request_params.pop("timeout", httpx.Timeout(600.0))— this makes the timeout configurable viarequest_params, soRestApiToolcan control timeout without modifying_request()in the future. - Instead of
None(no timeout), I set a generous 10-minute default as a safety net to prevent indefinite hangs while still accommodating slow API responses.
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.
While setting
timeout=Nonerestores the previous behavior ofrequestsand fixes the immediatehttpx.ReadTimeoutissue, it introduces a significant risk. Disabling timeouts can cause requests to hang indefinitely if the remote API is unresponsive, potentially leading to resource exhaustion and service instability.Even though a follow-up is mentioned in the pull request description, I strongly recommend addressing this now by setting a generous default timeout (e.g., 10 minutes) instead of
None. This would provide a crucial safety net. A truly indefinite timeout should be an explicit choice by the user of the tool, not the default behavior.