TooTallNate/node-proxy-agent

pac proxies trigger error about object is not a function

tehdeadone opened this issue · 3 comments

While using a http, https or socks proxy works fine, if the url is a .pac file, it seems trigger an error in pac-proxy-agent - where it tries to use proxy-agent to figure out the correct final proxy agent to use.

I've enabled debug using and I see this trace:

  pac-proxy-agent loading PAC file: "http://proxy/proxy.pac" +0ms
  pac-proxy-agent got stream.Readable instance for URI +10ms
  pac-proxy-agent read 6412 byte PAC file from URI +2ms
  pac-proxy-agent creating new proxy resolver instance +0ms
  pac-proxy-agent url: "https://demo.stwc.s3group.com/api/v1/login", host: "demo
.stwc.s3group.com" +231ms
  pac-proxy-agent using proxy: "PROXY avproxylan.dublin.s3group.com:8080" +3ms

c:\Users\markcu\Documents\WarningCenter\git\warningcenter\wsagents\s3_modules\pr
oxy\node_modules\proxy-agent\node_modules\pac-proxy-agent\index.js:243
      agent = ProxyAgent('http://' + parts[1], secure);
              ^
TypeError: object is not a function
    at onproxy (c:\Users\markcu\Documents\WarningCenter\git\warningcenter\wsagen
ts\s3_modules\proxy\node_modules\proxy-agent\node_modules\pac-proxy-agent\index.
js:243:15)
    at processImmediate [as _immediateCallback] (timers.js:345:15)

I can install pac-proxy-agent and use it directly and I do not get this error.

Are you sure you're using the latest versions of proxy-agent and pac-proxy-agent? I can't seem to reproduce this. Do you have some executable example code to help me reproduce the issue?

I am using the latest versions of both I believe:
Node version: v0.10.32

$ npm list | grep proxy-agent
├─┬ http-proxy-agent@0.2.6
├─┬ https-proxy-agent@0.3.5
├─┬ pac-proxy-agent@0.2.0
├─┬ proxy-agent@1.1.0
│ ├─┬ http-proxy-agent@0.2.6
│ ├─┬ pac-proxy-agent@0.2.0
│ └─┬ socks-proxy-agent@0.1.2
├─┬ socks-proxy-agent@0.1.2

(I'm currently knee deep in an agile sprint, but will get back to you with some executable code after)

Can you try again with v2.0.0 please? The circular dependency has been fixed/removed at this point.