fix: Ensure HTTP agent settings are used in VSCode with keepalives
Description
This is a part 2 relating to enabling connection reuse that depends on !1264 (merged).
As described in https://github.com/microsoft/vscode/issues/173861 and
&6244 (comment 615087584),
VSCode replaces the HTTP agent with vscode-proxy-agent
whenever the
http.proxysupport
setting is set to the default setting
(override
). This effectively prevents any custom settings, such as
keepAlive
, ca
, etc. from taking effect.
When http.proxySupport
is set to its default value (override
) and
no proxy setting is being used, the proxy library does not properly
reuse the agent set on the HTTPS method. Instead, it always uses a new
agent per request. To work around this, patch the default proxy agent
method and overwrite the originalAgent
value before invoking it for
requests that want to keep their connection alive, only when user is
not using their own HTTP proxy and the request contains Connection: keep-alive
.
This patch uses the same approach used in Cody and AWS CodeWhisperer.
Related Issues
Resolves #[issue_number]
How has this been tested?
- In VSCode set
Settings
->Settings
-> enterhttp:proxysupport
. - Make sure it's set to
override
tooff
.`. - Close down all your browsers to GitLab.com.
- Record all HTTPS traffic going to GitLab.com. If you are using macOS on WiFi, the interface will be
en0
:
sudo tcpdump -s 0 -w /tmp/gitlab.pcap host gitlab.com
Tip: you can check whether traffic is idle to gitlab.com by running sudo tcpdump -s 0 host gitlab.com
first and then hit CTRL-C to stop.
- Open VSCode and a GitLab.com project.
- As suggested by
@msmiley
, measure the number of TLS handshakes in the capture:
tshark -r /tmp/gitlab.pcap -Y 'tls.handshake.type == 1 && tls.handshake.extensions_server_name == "gitlab.com"' -T fields -e ip.dst -e tcp.srcport -e tls.handshake.extensions_server_name | sort | uniq -c | wc -l
This number should remain < 10 and not grow over time.
Screenshots (if appropriate):
Types of changes
-
Bug fix (non-breaking change which fixes an issue) -
New feature (non-breaking change which adds functionality) -
Breaking change (fix or feature that would cause existing functionality to change) -
Documentation -
Chore (Related to CI or Packaging to platforms) -
Test gap