Fix the `agent: null` http agent regression #7189

wants to merge 5 commits into


None yet

4 participants


See the individual commit messages for more details. I'd be fine with squashing this as well if you guys think that would be better. /cc @tjfontaine @indutny @bnoordhuis

See #7012.

TooTallNate added some commits Feb 25, 2014
@TooTallNate TooTallNate test: add failing http `agent: null` test
See #7012.
@TooTallNate TooTallNate http, https: don't depend on `globalAgent`
For the `request()` and `get()` functions. I could never
really understand why these two functions go through agent
first... Especially since the user could be passing `agent: false`
or a different Agent instance completely, in which `globalAgent`
will be completely bypassed.

Moved the relevant logic from `Agent#request()` into the
`ClientRequest` constructor.

Incidentally, this commit fixes #7012 (which was the original
intent of this commit).
@TooTallNate TooTallNate test: update "http-*" tests to only use public API
Don't invoke the `agent.requst()` or `agent.get()` functions
directly. Instead, use the public API and pass the agent
instance in as the `agent` option.
@TooTallNate TooTallNate http: remove the circular dependency
Between `ClientRequest` and `Agent`. The circular require was doing
weird things at load time, like making the `globalAgent` property
be `undefined` from within the context of the "_http_client"

Removing the circular dependency completely fixes this.

Thank you for contributing this pull request! Here are a few pointers to make sure your submission will be considered for inclusion.

The following commiters were not found in the CLA:

  • Nathan Rajlich

You can fix all these things without opening another issue.

Please see for more information


@bnoordhuis I'm also planning on fixing the createConnection option for you, which appears to be completely broken on master branch... That'll be a separate PR though most likely.


That looks like commit 7124387. Did that get lost somewhere along the way?

I suppose it should be broken out into a separate commit because it's not really related to the agent fix.


Wait, never mind - you're just moving it around.


Typo in commit log: s/requst/request/


LGTM. Cheers, Nathan.


/cc @isaacs TJ said that you had some reservations about agent.request()/agent.get(), which I'm removing here to eliminate the problematic cyclic dependency between Agent and ClientRequest. Did you have any comments about this?

indutny commented Feb 26, 2014

The test seems to be hanging in latest v0.10, mind having a look?

indutny commented Feb 26, 2014

Ah, it was with your createConnection patch.


hm? should you pass method in options?



indutny commented Feb 26, 2014

LGTM, I like it!

@TooTallNate TooTallNate added a commit to TooTallNate/node that referenced this pull request Feb 26, 2014
@TooTallNate TooTallNate test: add `agent: null` http client request test
This is just the test portion from #7012 / #7189,
but targetted for the v0.10 branch.

@indutny re: test failing on v0.10. There was an issue with the test I found. See TooTallNate@47abdd9 for a better test (I'll update this PR with the updated test as well).

@TooTallNate TooTallNate test: consume the response in `agent: null` test
Otherwise the process would hang open on v0.10
(though on master the old test would pass successfully).

Also adding counter checks for both the server's
"request" event and the client's "response" event.
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment