Skip to content
This repository was archived by the owner on Aug 20, 2020. It is now read-only.
This repository was archived by the owner on Aug 20, 2020. It is now read-only.

invoke the API callback upon Error #5

Closed
@cantremember

Description

@cantremember

Issue Summary

When an Error is emitted by the http or https ClientRequest, the callback to the API method is never invoked. Thus, the caller is never informed that the request failed, and will wait forever.

In our case, a series of HTTP timeouts from the SendGrid API caused all of our asynchronous Workers to lock up waiting for responses that would never come.

Steps to Reproduce

  1. In the Test Suite, use nock to simulate a failure

    nock(TEST_HOST)
      .get('/test')
      .replyWithError('ERROR')
  2. Invoke the Test Case's done callback within the API's callback (vs. synchronously, regardless of whether the API callback is invoked or not)

  3. This will result in Error: timeout of 2000ms exceeded

Technical details:

  • node-http-client Version: master (latest commit: c4785c6)
  • Node.js Version: agnostic

There are several strategies to resolving this issue:

  • provide a mocked HTTP 500 response so that the callback gets a parseable Object. this could be considered a 'patch' release, since it would not crash any code which blindly expects an Object with statusCode, body and headers properties
  • invoke the callback with no argument, or with null. this could be thought of as breaking the API, because attempting to access a property on the non-existing Object will crash the caller. perhaps it could be excusable as a 'minor' release. also, the caller has no access to the emitted Error itself
  • change the callback over to CPS style -- a more traditional Node.js (err, response) argument signature -- and provide the emitted Error. this is definitely a 'major' release, but it aligns very closely with the "consistent callback function signature" approach in Promise API and consistent callback function signature sendgrid-nodejs#261

Metadata

Metadata

Assignees

No one assigned

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions