Skip to content

HTTPS clone URL

Subversion checkout URL

You can clone with HTTPS or Subversion.

Download ZIP

Loading…

Request.prototype.toJSON is wrong in the head #387

Closed
othiym23 opened this Issue · 1 comment

1 participant

@othiym23

This crashes:

var request = require('request');

(function hambulance() {
  var req = request.head({
    url            : 'http://short.co/97k9',
    headers        : {
      'User-Agent': 'AppleWebKit/525.13 (KHTML, like Gecko) Safari/525.13.',
      'Connection': 'close'
    },
    followRedirect : false
  }, function (err, res, body) {
    var json = JSON.stringify(res);
    process.nextTick(hambulance);
  });
}());

This does not crash:

var request = require('request')
  , util = require('util')
  ;

(function hambulance() {
  var req = request.head({
    url            : 'http://short.co/97k9',
    headers        : {
      'User-Agent': 'AppleWebKit/525.13 (KHTML, like Gecko) Safari/525.13.',
      'Connection': 'close'
    },
    followRedirect : false
  }, function (err, res, body) {
    var json = util.inspect(res);
    process.nextTick(hambulance);
  });
}());

If you see https://gist.github.com/0d418c1d78a4e28445fe, you can see something that dumps more state about what's happening to the Socket object. Something in getSafe is doing something it shouldn't be doing to the Socket's underlying events listeners, and it's causing a 'close' event to be emitted incorrectly to boot.

Breaking cycles is hard!

@othiym23

This was fixed by #388. Thanks for merging, @mikeal!

@othiym23 othiym23 closed this
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Something went wrong with that request. Please try again.