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

Conversation

fengzhou-sg
Copy link

@fengzhou-sg fengzhou-sg commented Mar 21, 2025

Currently, keepAlive flag is ignored in this issue. This causes to keepAlive to be false at agent level, which prevents connection re-use for all endpoints (see nodejs Agent). While some servers may not support keep-alive well, globally disabling the flag seems too broad of impact. It would be great if clients can decide on whether to use keepAlive (through request's keepAlive) instead.

This PR changes the logic of passing keepAlive flag. If client uses a custom http or https agent, then pass its keepAlive flag in creation of PacProxyAgent.

If client uses a custom http or https agent, then pass its keepAlive flag in creation of PacProxyAgent.
@fengzhou-sg
Copy link
Author

@microsoft-github-policy-service agree company="Sourcegraph"

Copy link

@chrmarti chrmarti left a comment

Choose a reason for hiding this comment

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

Thanks for the PR, left two comments.

@@ -0,0 +1,200 @@
lockfileVersion: '9.0'
Copy link

Choose a reason for hiding this comment

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

This file slipped in. Please remove it from the PR.

@@ -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.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

2 participants