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
Timeout error handling #2890
Comments
ping @simov |
Could one of the request maintainers/developers please answer my questions? |
@simov ping |
@kevinburke saw you added the current README information in #1711 (#1660). Could you weigh in on suggested client-side error checking/reporting? Further reading what you wrote (and various test cases) implies at minimum checks for 3 specific errors (ETIMEDOUT w/ connect, ETIMEDOUT w/o connect, and ESOCKETTIMEDOUT). Can't decide whether ECONNRESET should join them. |
This look reasonable for client-side error handling? Any other somewhat possible errors to deal with? if typeof @request.body is 'string'
body = @request.body
else
body = JSON.stringify @request.body
options =
body: body,
headers: @request.headers,
method: @request.method,
qs: @request.query,
timeout: 5000, # Five seconds
url: @url()
makeHTTPRequest = (callback) ->
requestCB = (error, response, body) ->
if error
maybeReplaceMessage = (error) ->
error.message = switch
when error?.code == 'ETIMEDOUT' and error?.connect
'timed out attempting to establish connection'
when error?.code == 'ETIMEDOUT'
'timed out awaiting server response'
when error?.code == 'ESOCKETTIMEDOUT'
'timed out when server stopped sending response data'
when error?.code == 'ECONNRESET'
'connection reset by server'
else
error.message
return error
return callback maybeReplaceMessage error
return callback null, response, body
request options, requestCB |
So it's been a year now -- still not even an acknowledgement this was even read by a maintainer... |
This issue has been automatically marked as stale because it has not had recent activity. It will be closed if no further activity occurs. Thank you for your contributions. |
Read Timeouts section of documentation.
After glancing the related code here as well as here and here, I was left with a few questions.
README
suggestions still correct? Looks more like ETIMEDOUT error is exclusively connection-related, and ESOCKETTIMEDOUT read-related.For 3, the
errno
-based names are already included aserror.code
. As such, coulderror.message
be made more human readable [e.g., ETIMEDOUT->new Error("server took too long to connect")
]?The text was updated successfully, but these errors were encountered: