Node-Fetch Slow When Using Proxy
walmat opened this issue · 0 comments
Describe the bug
There have been several reports from users that claimed that node-fetch is really slow when operating behind a proxy. It's fine when using localhost, but it gets laggy when connected to any proxy requiring a TCP connection.
I looked into this and I believe it stems from the HttpsProxyAgent I was using to connect to the proxy. Node fetch by default sets keep-alive
to true, but HttpsProxyAgent overrides this when connected to a proxy. This causes the keep-alive
to be false, which in turn causes a need for the fetch package to reinitialize the TCP connection every time it calls a request.
To Reproduce
Steps to reproduce the behavior:
I'd list these here, but it's pretty unnecessary imho.
Expected behavior
We should only receive latency when connecting to a proxy that stems from the actual connection the first time and not the re-initialization of the connection every time a request is made.
Screenshots
N/A
Desktop (please complete the following information):
- OS: ALL
- Service: Task Runner [GLOBAL]
- Version: 1.2.35+
Additional context
I'm in favor of switching to axios. It has a similar API and native proxy support that doesn't override the keep-alive
header. Any other suggestions, please post them in the comments below!