fbgraph icon indicating copy to clipboard operation
fbgraph copied to clipboard

Double callback on GET request timeout

Open deandum opened this issue 4 years ago • 1 comments

With the recent issue that Facebook had, we have been getting a lot of errors generated by the code below:

return request.get(this.options, function(err, res, body) {
    if (err) {
      self.callback({
          message: 'Error processing https request'
        , exception: err
      }, null);

      return;
    }

    if (~res.headers['content-type'].indexOf('image')) {
      body = {
          image: true
        , location: res.headers.location
      };
    }

    self.end(body);
  }).on('error', function(err) {
     self.callback({
          message: 'Error processing https request'
        , exception: err
      }, null);
  });

The error is caught twice here, resulting in double callbacks and may cause uncaught exceptions if not handled properly.

deandum avatar Oct 07 '21 17:10 deandum

Lol, this was driving me crazy. Ty!

Sirach99 avatar Apr 29 '24 06:04 Sirach99