-
Notifications
You must be signed in to change notification settings - Fork 4.8k
feat: support proxy in connect/connectOverCDP #35389
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
Conversation
This comment has been minimized.
This comment has been minimized.
228e382 to
6f8aff5
Compare
This comment has been minimized.
This comment has been minimized.
| if (params.proxy) { | ||
| options.agent = createProxyAgent(params.proxy, new URL(params.url)); | ||
| } else { | ||
| const proxyURL = getProxyForUrl(params.url); |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
This is hard to follow imo. The first if-condition is 'if there is a user-specified proxy'. The second condition is 'getProxyForUrl' but in reality its 'getProxyFromEnvForUrl'. I think we can do something like this:
const proxyFromEnv = getProxyForUrl(params.url);
const proxyFromEnvObj = proxyFromEnv ? { server: proxyFromEnv } : undefined;
options.agent = createProxyAgent(params.proxy ?? proxyFromEnvObj, new URL(params.url));This in theory should allow us to get rid f the whole "else clause" This has one disadvantage tho after thinking about it. It would end up that we do CONNECT requests for all the http requests. It would mean we would have to move the options = either into createProxyAgent or add the HttpProxyAgent dependency which seems reasonable (one dependency from the same author of https-proxy-agent`). Maybe follow-up and get rid of the TODO in createProxyAgent?
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I am afraid to touch this willy-nilly because it is used for the npx playwright install. Therefore I made the smallest change possible by respecting the user-supplied proxy if any. We can try to follow up with some opt-out env variable, or leave with it for one more release.
6f8aff5 to
256f5c3
Compare
Test results for "tests others"3 flaky21846 passed, 506 skipped Merge workflow run. |
Test results for "tests 1"1 failed 2 flaky38914 passed, 805 skipped Merge workflow run. |
Test results for "tests 2"2 fatal errors, not part of any test 107 flaky241352 passed, 9402 skipped Merge workflow run. |
This reverts commit 471a28e. Reason: decided to skip an explicit API and instead follow Node.js attempts to supports HTTP_PROXY and HTTPS_PROXY.
Extracted from microsoft#35389. No behavior change whatsoever.
Closes #35206, closes #33894.