criso / fbgraph

NodeJs module to access the facebook graph api
http://criso.github.io/fbgraph/
1.09k stars 174 forks source link

Double callback on GET request timeout #145

Open deandum opened 2 years ago

deandum commented 2 years ago

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.

Sirach99 commented 5 months ago

Lol, this was driving me crazy. Ty!