delvedor / delvedor/hpagent

Ignoring maxSockets

Open
#12 1 comment 0 reactions 0 assignees View on GitHub
Dominant language
JavaScript
Stars
192
Forks
40
PR merge metrics
No merged PRs in 30d

Description

It seems maxSockets agent option is ignored when HttpProxyAgent is used.

```javascript
const got = require('got');
const { HttpProxyAgent } = require('hpagent')
const http = require('http')

const opts = {
maxSockets: 1,
proxy: 'http://localhost:5555'
};
const hpagent = new HttpProxyAgent(opts);

const start = new Date();
const elapsed = () => { return (new Date().getTime() - start.getTime()) / 1000.0 }

// They run parallel on 2 different sockets, ignoring maxSockets
got('http://httpbin.org/delay/3', {
agent: {
http: hpagent
}
}).then(() => console.log(`hpagent Request1 done in : ${elapsed()}`));

got('http://httpbin.org/delay/3', {
agent: {
http: hpagent
}
}).then(() => console.log(`hpagent Request2 done in : ${elapsed()}`));

const agent = new http.Agent(opts);
// They run sequentially as maxSockets is 1
got('http://httpbin.org/delay/4', {
agent: {
http: agent
}
}).then(() => console.log(`http.agent Request1 done in : ${elapsed()}`));

got('http://httpbin.org/delay/4', {
agent: {
http: agent
}
}).then(() => console.log(`http.agent Request2 done in : ${elapsed()}`));

```

Console output is :
```
hpagent Request1 done in : 3.414
hpagent Request2 done in : 3.631
http.agent Request1 done in : 4.413
http.agent Request2 done in : 8.607
```
As you see, in contrast to http.Agent, hpagent sends second request immediately, without waiting for first socket to finish.

Contributor guide

No contributing guide indexed for this repository

Research direction

Reproduce the issue with the provided got, HttpProxyAgent, and http.Agent example, then inspect how HttpProxyAgent handles maxSockets compared with Node's http.Agent. Done means two delayed requests using one HttpProxyAgent socket run sequentially when maxSockets is 1, matching the demonstrated http.Agent behavior.

Written by the indexing model from the issue text.

Assessment

Tech stack
javascript
Domain
backend, networking
Issue type
Bug
Difficulty
3/5
Estimated time
1-2 days
Activity status
Stale
Clarity
Mostly clear
Newbie friendliness
35/100

Get new issues in your inbox

A short digest of beginner-friendly GitHub issues.