Skip to content
This repository was archived by the owner on May 5, 2023. It is now read-only.

Commit d18c6bd

Browse files
Update agent-base to v6 (#55)
- small changes to adapt to new api - updated proxy dependencies that use agent-base@6
1 parent 4af6f5e commit d18c6bd

File tree

2 files changed

+10
-8
lines changed

2 files changed

+10
-8
lines changed

index.js

Lines changed: 5 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -144,7 +144,7 @@ function mapOptsToProxy(opts) {
144144
function ProxyAgent (opts) {
145145
if (!(this instanceof ProxyAgent)) return new ProxyAgent(opts);
146146
debug('creating new ProxyAgent instance: %o', opts);
147-
Agent.call(this, connect);
147+
Agent.call(this);
148148

149149
if (opts) {
150150
var proxy = mapOptsToProxy(opts);
@@ -159,7 +159,7 @@ inherits(ProxyAgent, Agent);
159159
*
160160
*/
161161

162-
function connect (req, opts, fn) {
162+
ProxyAgent.prototype.callback = function(req, opts, fn) {
163163
var proxyOpts = this.proxy;
164164
var proxyUri = this.proxyUri;
165165
var proxyFn = this.proxyFn;
@@ -193,6 +193,8 @@ function connect (req, opts, fn) {
193193
agent.addRequest(req, opts);
194194
} else {
195195
// XXX: agent.callback() is an agent-base-ism
196-
agent.callback(req, opts, fn);
196+
agent.callback(req, opts)
197+
.then(function(socket) { fn(null, socket); })
198+
.catch(function(error) { fn(error); });
197199
}
198200
}

package.json

Lines changed: 5 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -29,14 +29,14 @@
2929
},
3030
"homepage": "https://github.com/TooTallNate/node-proxy-agent",
3131
"dependencies": {
32-
"agent-base": "^4.2.0",
32+
"agent-base": "^6.0.0",
3333
"debug": "4",
34-
"http-proxy-agent": "^2.1.0",
35-
"https-proxy-agent": "^3.0.0",
34+
"http-proxy-agent": "^4.0.0",
35+
"https-proxy-agent": "^5.0.0",
3636
"lru-cache": "^5.1.1",
37-
"pac-proxy-agent": "^3.0.1",
37+
"pac-proxy-agent": "^4.1.0",
3838
"proxy-from-env": "^1.0.0",
39-
"socks-proxy-agent": "^4.0.1"
39+
"socks-proxy-agent": "^5.0.0"
4040
},
4141
"devDependencies": {
4242
"@types/agent-base": "^4.2.0",

0 commit comments

Comments
 (0)