forwardemail / forwardemail/superagent

TCP reuse

Open
#1,584 5 comments 4 reactions 0 assignees View on GitHub
Dominant language
JavaScript
Stars
16.6k
Forks
1.3k
PR merge metrics
No merged PRs in 30d

Description

Hi,
I'm using superagent and while inspecting the network I noticed that superagent is creating a new TCP connection for each request. I'm using superagent for a sequence of requests which results in a large number of TCP connections (can reach several hundreds).

I tried to follow [this idea](https://github.com/visionmedia/superagent/issues/547) and use `agentkeepalive` package however this approach has some downsides:

1. While superagent works out-of-the-box with http and https, `agentkeepalive` needs to be defined per protocol.
2. As a result of the previous section, in case I do an http request that redirects to https request I get an error of `Protocol "https:" not supported. Expected "http:"` since the protocol has changed.
3. As a result of section 2 the app crushes since with an `uncaughtException` (which happens only upon redirects and not when using the wrong protocol i.e. the http `agentkeepalive` for https request)

Needless to say that using `request.set('Connection', 'keep-alive');` didn't solve it.

My questions are:

1. Is there un updated solution for the keep-alive problem?
2. Is there a built-in option in superagent to define the reuse of TCP connections? If not, is there a plan to support one?

Thanks

Contributor guide

Open the contributing guide

Assessment

This issue has not been assessed yet.

Get new issues in your inbox

A short digest of beginner-friendly GitHub issues.