Skip to content
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

Closed
plroebuck opened this issue Mar 10, 2018 · 7 comments
Closed

Timeout error handling #2890

plroebuck opened this issue Mar 10, 2018 · 7 comments
Labels

Comments

@plroebuck
Copy link

plroebuck commented Mar 10, 2018

Read Timeouts section of documentation.
After glancing the related code here as well as here and here, I was left with a few questions.

  1. Are README suggestions still correct? Looks more like ETIMEDOUT error is exclusively connection-related, and ESOCKETTIMEDOUT read-related.
  2. Should client-side code also be checking for ESOCKETTIMEDOUT and ECONNRESET?
  3. Could you change the Error messages to something useful to user?

For 3, the errno-based names are already included as error.code. As such, could error.message be made more human readable [e.g., ETIMEDOUT-> new Error("server took too long to connect")]?

@plroebuck
Copy link
Author

ping @simov

@plroebuck
Copy link
Author

Could one of the request maintainers/developers please answer my questions?
It's been over 3 weeks...

@plroebuck
Copy link
Author

@simov ping

@plroebuck
Copy link
Author

plroebuck commented Apr 3, 2018

@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.

@plroebuck
Copy link
Author

plroebuck commented Apr 11, 2018

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

@plroebuck
Copy link
Author

So it's been a year now -- still not even an acknowledgement this was even read by a maintainer...

@stale
Copy link

stale bot commented Mar 9, 2020

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.

@stale stale bot added the stale label Mar 9, 2020
@stale stale bot closed this as completed Mar 16, 2020
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
Projects
None yet
Development

No branches or pull requests

1 participant