assaf/node-replay

Https requests are hanging

maxkferg opened this issue · 5 comments

When trying to request the following url, the requests just hang:
When node-replay is disabled the requests work fine.

https://api.mailgun.net:443/v2/maxkferg.mailgun.org/messages.mime

I'm not sure if it is because of the :443 or the https prefix.

I'm having the same issue.

  • If I remove replay, it works.
  • If I change the request to HTTP, with or without replay, I can record it.
  • If I have it in replay mode, it works (by blocking the request)

I just cannot get it to record or go through, even in bloody mode.

Here's the error I get:

querystring.js:0
(null)

RangeError: Maximum call stack size exceeded

Just got hit by this issue and think I've tracked it down.

In pass_through.coffee at the top it captures the original http/https request functions in order to use them further down. However, the code of https.request is (looking at 0.12.0)

function (options, cb) {
  if (util.isString(options)) {
    options = url.parse(options);
  } else {
    options = util._extend({}, options);
  }
  options._defaultAgent = globalAgent;
  return http.request(options, cb);
}

By the time that function calls http.request, the request object has already been switched out for the proxy one. So this just creates an infinite loop of proxy-ing.

I've hacked a fix together whereby I have basically copied the code of https.request into pass_through.coffee, and call http.request instead. This seems to work for me, I'll create a PR but might require a lot more thought.

@joewoodhouse can you share your fix for this? I'm hitting the same issue, detailed more here: #60

This is the fix on my fork: joewoodhouse@3711240

I'll try and create a pull request when I can sort out the merge conflicts

These issues should be fixed in master, please test again and report back.