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

Double callback on GET request timeout #145

Open
deandum opened this issue Oct 7, 2021 · 1 comment · May be fixed by #148
Open

Double callback on GET request timeout #145

deandum opened this issue Oct 7, 2021 · 1 comment · May be fixed by #148

Comments

@deandum
Copy link

deandum commented Oct 7, 2021

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
Copy link

Lol, this was driving me crazy. Ty!

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging a pull request may close this issue.

2 participants