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

TypeError: self.agent.addRequest is not a function when using custom httpAgent from global default #1077

Open
rupesh1 opened this Issue Sep 7, 2017 · 5 comments

Comments

Projects
None yet
4 participants
@rupesh1
Copy link

rupesh1 commented Sep 7, 2017

#### Summary
Trying to use Axios on Node with your own http(s)Agent set via the global default triggers the error: TypeError: self.agent.addRequest is not a function

For minimal example see: https://runkit.com/rupesh/59b1bcc1efc2f800128b7d54

It seems to be related to utils.merge not considering/handling the prototype chain:
developer_tools_-_node_js

Stack trace:

TypeError: self.agent.addRequest is not a function
at new ClientRequest in core _http_client.js — line 160
at http.Agent in core http.js — line 31
at RedirectableRequest._performRequest in follow-redirects/index.js — line 73
at Writable.RedirectableRequest in follow-redirects/index.js — line 57
at wrappedProtocol.request in follow-redirects/index.js — line 229
at dispatchHttpRequest in axios/lib/adapters/http.js — line 131
at httpAdapter in axios/lib/adapters/http.js — line 18

#### Context

  • axios version: 0.16.2
  • Environment: node v4, 6, 7 and 8

@rupesh1 rupesh1 changed the title TypeError: self.agent.addRequest is not a function when using custom httpAgent TypeError: self.agent.addRequest is not a function when using custom httpAgent from global default Sep 7, 2017

@rupesh1

This comment has been minimized.

Copy link

rupesh1 commented Sep 7, 2017

In hindsight this maybe another manifestation of: #812

@KamiKillertO

This comment has been minimized.

Copy link

KamiKillertO commented Jan 12, 2018

🤔 it's seems that utils.merge erase the httpAgent prototype.

@david4City

This comment has been minimized.

Copy link

david4City commented Jan 25, 2018

Anything on this subject ?

@KamiKillertO

This comment has been minimized.

Copy link

KamiKillertO commented Jan 25, 2018

There's a pending PR (#1295) that should fix this issue.

@cybercussion

This comment has been minimized.

Copy link

cybercussion commented Mar 27, 2018

I got this error on a self-signed cert. Initially I attempted to use httpsAgent: { rejectUnauthorized: false } but then opted to use httpsAgent: new https.Agent({ rejectUnauthorized: false }) and the error went away. Case someone else has that issue.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment