Skip to content

Pass keepAlive from custom agent #68

New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Open
wants to merge 1 commit into
base: main
Choose a base branch
from
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
3 changes: 3 additions & 0 deletions CHANGELOG.md
Original file line number Diff line number Diff line change
@@ -1,6 +1,9 @@
# Change Log
Notable changes will be documented here.

## [0.32.1]
- Pass on keepAlive flag for non-global agent ([microsoft/vscode#243482](https://github.com/microsoft/vscode/issues/243482))

## [0.32.0]
- Check both system certificates settings for `fetch` ([microsoft/vscode-proxy-agent#66](https://github.com/microsoft/vscode-proxy-agent/pull/66))

Expand Down
2 changes: 1 addition & 1 deletion package.json
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
{
"name": "@vscode/proxy-agent",
"version": "0.32.0",
"version": "0.32.1",
"description": "NodeJS http(s) agent implementation for VS Code",
"main": "out/index.js",
"types": "out/index.d.ts",
Expand Down
200 changes: 200 additions & 0 deletions pnpm-lock.yaml

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

2 changes: 1 addition & 1 deletion src/index.ts
Original file line number Diff line number Diff line change
Expand Up @@ -395,7 +395,7 @@ export function createHttpPatch(params: ProxyAgentParams, originals: typeof http
const agent = createPacProxyAgent(resolveP, {
originalAgent: (!useProxySettings || isLocalhost || config === 'fallback') ? originalAgent : undefined,
lookupProxyAuthorization: params.lookupProxyAuthorization,
// keepAlive: ((originalAgent || originals.globalAgent) as { keepAlive?: boolean }).keepAlive, // Skipping due to https://github.com/microsoft/vscode/issues/228872.
keepAlive: (typeof originalAgent === 'object') && (originalAgent !== originals.globalAgent) && (originalAgent as {keepAlive?: boolean}).keepAlive,
_vscodeTestReplaceCaCerts: (options as SecureContextOptionsPatch)._vscodeTestReplaceCaCerts,
}, opts => new Promise<void>(resolve => addCertificatesToOptionsV1(params, params.addCertificatesV1(), opts, resolve)));
agent.protocol = isHttps ? 'https:' : 'http:';
Expand Down
3 changes: 1 addition & 2 deletions tests/test-client/src/direct.test.ts
Original file line number Diff line number Diff line change
Expand Up @@ -158,8 +158,7 @@ describe('Direct client', function () {
});
assert.ok(seen, 'Original agent not called!');
});
it.skip('should reuse socket with agent', async function () {
// Skipping due to https://github.com/microsoft/vscode/issues/228872.
it('should reuse socket with agent', async function () {
// https://github.com/microsoft/vscode/issues/173861
const { resolveProxyWithRequest: resolveProxy } = vpa.createProxyResolver(directProxyAgentParams);
const patchedHttps: typeof https = {
Copy link

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

The two requests below need a custom agent with keepAlive = true for the socket to be reused.

Expand Down