-
Notifications
You must be signed in to change notification settings - Fork 984
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
Clarify diff between connection settings timeout
and open_timeout
#1470
Conversation
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 think Env#request
comes from this code, so it seems to be an instance of RequestOptions
.
faraday/lib/faraday/request.rb
Lines 127 to 128 in 20a5d57
Env.new(http_method, body, connection.build_exclusive_url(path, params), | |
options, headers, connection.ssl, connection.parallel_manager) |
In the first place, the description of Env#request
doesn't tell the all attributes of RequestOptions
, such as read_timeout
or write_timeout
. Ideally, I think RequestOptions
should have its own attribute documents, and it might be good for this request
to just tell return [RequestOptions]
.
However, it might require more work to add full explanations to RequestOptions
. How about adding read_timeout
and write_timeout
as well?
Note open_timeout
, read_timeout
, and write_timeout
will be referred by #request_timeout
, and it depends on adapters how they will be used. For example, faraday-net_http sets open_timeout
here, but #request_timeout
will fall back to timeout
when open_timeout
is not set. I could be wrong, but "total timeout for both the connection-opening phase and the reading phase" might not be correct.
Thank you for looking into this and the comment.
When I created this PR, I am not certain about what it does as well. If this might not be correct, do you know what would be correct instead? To be specific, let's say we have the following phase when we make a request using
Does Does Please let me know if have a mistake in understanding anywhere. |
This is where faraday/lib/faraday/adapter.rb Line 90 in 20a5d57
In faraday-net_http,
Yes in faraday-net_http, but I'm not sure why the code comment says " |
For
so I think the understanding around I will update the code for my PR to reflect that. |
In the future, it's probably better if we can expose But for now I have expanded the explanation comment to point out that there is an uncertainty on how the |
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.
The explanation looks good 👍
OK so it looks like we have some outdated documentation in this file.
The revised documentation should note all 4 timeout types and then make clear that |
Thanks for the explanation @iMacTia According to the comment in #1470 (comment), it seems like the Would you say that it is using the faraday's faraday/lib/faraday/adapter.rb Line 90 in 20a5d57
When both |
I have updated the comment again according to our discussion, if the formatting or explanation is incorrect, please let me know. I'm happy to change them. |
I haven't touched that code in a while, so a couple of questions come up on the Net::HTTP internals:
|
If Net::HTTP does indeed support a global timeout, then I agree we should set that instead, but I'd be surprised we're not using that already 🤔 |
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.
Changes to the docs are good 🙌!
We can continue discussing adapters implementation and the need to fix them, but this is the expected behaviour
I see, thanks for the response, I don't know much about how the Net::HTTP works but this has answered my question. I don't have the permission to merge this PR but I'm happy for this PR to be merged |
Co-authored-by: Olle Jonsson <[email protected]>
Description
This PR aims to clarify the difference between the config settings
timeout
andopen_timeout
.I am very confused about the difference between
timeout
andopen_timeout
.Originally, the comment for these 2 config settings says:
open_timeout
is described asread timeout Integer in seconds
but the previous line has the wordopen
in it, which suggests thatread
is something other thanopen
which is confusing because I expectopen_timeout
to representopen
.timeout
is described asopen/read
which is slightly ambiguous because I find it hard to tell which one of the following it means:Also when I was looking at this, I don't really know about TCP connection phase and reading phase and whether they are exclusive of each so searching online to clarify this is difficult as well. I found it difficult to clarify whether
timeout
actually includes the time inopen_timeout
and I have asked a question in here: #1469.The reason that I think
timeout
includesopen_timeout
is because:faraday
gem using thetyphoeus
adapter in this file:faraday/lib/faraday/adapter/typhoeus.rb
Line 12 in e7bbb4e
faraday
'stimeout
is represented bytimeout_ms
intyphoeus
andfaraday
'sopen_timeout
is represented byconnecttimeout_ms
intyphoeus
according to this filetyphoeus
gem README.md. It says