Skip to content

Conversation

@dgozman
Copy link
Contributor

@dgozman dgozman commented Mar 27, 2025

Closes #35206, closes #33894.

@github-actions

This comment has been minimized.

@dgozman dgozman force-pushed the feat-connect-proxy branch from 228e382 to 6f8aff5 Compare March 27, 2025 14:18
@github-actions

This comment has been minimized.

if (params.proxy) {
options.agent = createProxyAgent(params.proxy, new URL(params.url));
} else {
const proxyURL = getProxyForUrl(params.url);
Copy link
Contributor

@mxschmitt mxschmitt Mar 28, 2025

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?

Copy link
Contributor Author

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.

@dgozman dgozman force-pushed the feat-connect-proxy branch from 6f8aff5 to 256f5c3 Compare March 28, 2025 10:04
@dgozman dgozman added the CQ1 label Mar 28, 2025
@github-actions
Copy link
Contributor

Test results for "tests others"

3 flaky ⚠️ [electron-page] › tests/page/page-request-continue.spec.ts:72:3 › should delete header with undefined value @electron-macos-latest
⚠️ [electron-page] › tests/page/page-request-continue.spec.ts:72:3 › should delete header with undefined value @electron-ubuntu-latest
⚠️ [electron-page] › tests/page/page-request-continue.spec.ts:72:3 › should delete header with undefined value @electron-windows-latest

21846 passed, 506 skipped
✔️✔️✔️

Merge workflow run.

@github-actions
Copy link
Contributor

Test results for "tests 1"

1 failed
❌ [playwright-test] › tests/reporter-html.spec.ts:2747:5 › created › execSync doesnt produce a second stdout attachment @macos-latest-node18-2

2 flaky ⚠️ [firefox-page] › tests/page/page-evaluate.spec.ts:424:3 › should throw for too deep reference chain @firefox-ubuntu-22.04-node18
⚠️ [webkit-page] › tests/page/page-screenshot.spec.ts:345:5 › page screenshot › should work while navigating @webkit-ubuntu-22.04-node18

38914 passed, 805 skipped
✔️✔️✔️

Merge workflow run.

@github-actions
Copy link
Contributor

Test results for "tests 2"

2 fatal errors, not part of any test
15 failed
❌ [chromium-library] › tests/library/browsertype-connect.spec.ts:439:5 › run-server › should respect selectors @chrome-macos-latest
❌ [chromium-library] › tests/library/browsertype-connect.spec.ts:484:5 › run-server › should not throw on close after disconnect @chrome-macos-latest
❌ [chromium-library] › tests/library/browsertype-connect.spec.ts:495:5 › run-server › should saveAs videos from remote browser @chrome-macos-latest
❌ [chromium-library] › tests/library/inspector/cli-codegen-2.spec.ts:454:7 › cli codegen › should save assets via SIGINT @chrome-macos-latest
❌ [chromium-library] › tests/library/inspector/cli-codegen-csharp.spec.ts:171:5 › should work with --save-har @chrome-macos-latest
❌ [chromium-library] › tests/library/inspector/cli-codegen-csharp.spec.ts:182:5 › should work with --save-har and --save-har-glob @chrome-macos-latest
❌ [chromium-library] › tests/library/inspector/cli-codegen-csharp.spec.ts:216:7 › should work with --save-har in nunit @chrome-macos-latest
❌ [chromium-library] › tests/library/downloads-path.spec.ts:77:5 › downloads path › should report downloads in downloadsPath folder with a relative path @msedge-dev-macos-latest
❌ [chromium-library] › tests/library/downloads-path.spec.ts:91:5 › downloads path › should accept downloads in persistent context @msedge-dev-macos-latest
❌ [chromium-library] › tests/library/downloads-path.spec.ts:105:5 › downloads path › should delete downloads when persistent context closes @msedge-dev-macos-latest
❌ [webkit-library] › tests/library/proxy.spec.ts:326:3 › should use http proxy for websocket requests @webkit-macos-13-large
❌ [webkit-library] › tests/library/proxy.spec.ts:326:3 › should use http proxy for websocket requests @webkit-macos-13-xlarge
❌ [webkit-library] › tests/library/tracing.spec.ts:432:14 › should produce screencast frames fit @webkit-macos-13-xlarge
❌ [webkit-library] › tests/library/tracing.spec.ts:432:14 › should produce screencast frames crop @webkit-macos-13-xlarge
❌ [webkit-library] › tests/library/tracing.spec.ts:432:14 › should produce screencast frames scale @webkit-macos-13-xlarge

107 flaky ⚠️ [chromium-library] › tests/library/browser.spec.ts:54:5 › should dispatch page.on(close) upon browser.close and reject evaluate @channel-chromium-macos-latest
⚠️ [chromium-library] › tests/library/browsercontext-base-url.spec.ts:37:3 › should construct a new URL when a baseURL in browserType.launchPersistentContext is passed to page.goto @channel-chromium-macos-latest
⚠️ [chromium-library] › tests/library/beforeunload.spec.ts:20:3 › should close browser with beforeunload page @chrome-beta-macos-latest
⚠️ [chromium-library] › tests/library/browser.spec.ts:54:5 › should dispatch page.on(close) upon browser.close and reject evaluate @chrome-beta-macos-latest
⚠️ [chromium-library] › tests/library/inspector/cli-codegen-2.spec.ts:454:7 › cli codegen › should save assets via SIGINT @chrome-beta-macos-latest
⚠️ [chromium-library] › tests/library/inspector/cli-codegen-3.spec.ts:737:7 › cli codegen › should assert value @chrome-beta-macos-latest
⚠️ [chromium-library] › tests/library/inspector/cli-codegen-csharp.spec.ts:171:5 › should work with --save-har @chrome-beta-macos-latest
⚠️ [chromium-library] › tests/library/video.spec.ts:379:5 › screencast › should capture navigation @chrome-beta-macos-latest
⚠️ [chromium-library] › tests/library/inspector/cli-codegen-aria.spec.ts:76:7 › should update aria snapshot highlight @chrome-beta-windows-latest
⚠️ [chromium-library] › tests/library/browser.spec.ts:54:5 › should dispatch page.on(close) upon browser.close and reject evaluate @chrome-macos-latest
⚠️ [chromium-library] › tests/library/browsercontext-base-url.spec.ts:37:3 › should construct a new URL when a baseURL in browserType.launchPersistentContext is passed to page.goto @chrome-macos-latest
⚠️ [chromium-library] › tests/library/browsertype-connect.spec.ts:670:5 › run-server › should fulfill with global fetch result @chrome-macos-latest
⚠️ [chromium-library] › tests/library/browsertype-launch-server.spec.ts:23:5 › launch server › should work @chrome-macos-latest
⚠️ [chromium-library] › tests/library/chromium/connect-over-cdp.spec.ts:125:5 › should connect to an existing cdp session twice @chrome-macos-latest
⚠️ [chromium-library] › tests/library/inspector/cli-codegen-pytest.spec.ts:57:5 › should save the codegen output to a file if specified @chrome-macos-latest
⚠️ [chromium-library] › tests/library/inspector/cli-codegen-python-async.spec.ts:158:5 › should work with --save-har and --save-har-glob @chrome-macos-latest
⚠️ [chromium-library] › tests/library/inspector/cli-codegen-python.spec.ts:78:5 › should save the codegen output to a file if specified @chrome-macos-latest
⚠️ [chromium-library] › tests/library/inspector/cli-codegen-test.spec.ts:99:5 › should generate routeFromHAR with --save-har @chrome-macos-latest
⚠️ [chromium-library] › tests/library/logger.spec.ts:19:3 › should log @smoke @chrome-macos-latest
⚠️ [chromium-library] › tests/library/inspector/console-api.spec.ts:45:3 › should support playwright.selector @chrome-windows-latest
⚠️ [chromium-library] › tests/library/video.spec.ts:379:5 › screencast › should capture navigation @chrome-windows-latest
⚠️ [chromium-library] › tests/library/inspector/pause.spec.ts:529:5 › pause › should record from debugger @chromium-headed-ubuntu-24.04
⚠️ [chromium-page] › tests/page/page-mouse.spec.ts:244:3 › should tween mouse movement @chromium-headed-ubuntu-24.04
⚠️ [chromium-page] › tests/page/page-screenshot.spec.ts:650:5 › page screenshot animations › should stop animations that happen right before screenshot @chromium-macos-13-xlarge
⚠️ [chromium-library] › tests/library/inspector/cli-codegen-1.spec.ts:23:7 › cli codegen › should click @chromium-tip-of-tree-headless-shell-ubuntu-22.04
⚠️ [chromium-library] › tests/library/inspector/cli-codegen-java.spec.ts:105:5 › should work with --save-har and --save-har-glob as java-junit @chromium-tip-of-tree-headless-shell-ubuntu-22.04
⚠️ [chromium-library] › tests/library/trace-viewer.spec.ts:966:1 › should show action source @chromium-tip-of-tree-ubuntu-22.04--headed
⚠️ [chromium-library] › tests/library/inspector/cli-codegen-pick-locator.spec.ts:35:7 › should update locator highlight @chromium-windows-latest
⚠️ [chromium-page] › tests/page/page-request-continue.spec.ts:72:3 › should delete header with undefined value @chromium-windows-latest
⚠️ [firefox-library] › tests/library/video.spec.ts:163:5 › screencast › should work with old options @firefox-beta-macos-latest
⚠️ [firefox-page] › tests/page/page-evaluate.spec.ts:424:3 › should throw for too deep reference chain @firefox-beta-ubuntu-22.04
⚠️ [firefox-page] › tests/page/page-evaluate.spec.ts:424:3 › should throw for too deep reference chain @firefox-beta-windows-latest
⚠️ [firefox-library] › tests/library/capabilities.spec.ts:252:3 › requestFullscreen @firefox-headed-macos-14-xlarge
⚠️ [firefox-library] › tests/library/inspector/cli-codegen-aria.spec.ts:76:7 › should update aria snapshot highlight @firefox-headed-macos-14-xlarge
⚠️ [firefox-page] › tests/page/page-evaluate.spec.ts:424:3 › should throw for too deep reference chain @firefox-headed-ubuntu-24.04
⚠️ [firefox-library] › tests/library/browsercontext-basic.spec.ts:331:3 › should emulate media in cross-process iframe @firefox-headed-windows-latest
⚠️ [firefox-library] › tests/library/browsercontext-proxy.spec.ts:203:3 › should work with IP:PORT notion @firefox-headed-windows-latest
⚠️ [firefox-library] › tests/library/capabilities.spec.ts:67:3 › should play video @smoke @firefox-headed-windows-latest
⚠️ [firefox-library] › tests/library/capabilities.spec.ts:82:3 › should play webm video @smoke @firefox-headed-windows-latest
⚠️ [firefox-library] › tests/library/download.spec.ts:123:5 › download event › should report downloads with acceptDownloads: true @firefox-headed-windows-latest
⚠️ [firefox-library] › tests/library/emulation-focus.spec.ts:25:3 › should think that all pages are focused @smoke @firefox-headed-windows-latest
⚠️ [firefox-library] › tests/library/hit-target.spec.ts:398:3 › should click in iframe with padding @firefox-headed-windows-latest
⚠️ [firefox-library] › tests/library/inspector/cli-codegen-3.spec.ts:222:7 › cli codegen › should generate frame locators (4) @firefox-headed-windows-latest
⚠️ [firefox-library] › tests/library/inspector/cli-codegen-3.spec.ts:636:7 › cli codegen › should consume pointer events @firefox-headed-windows-latest
⚠️ [firefox-library] › tests/library/inspector/cli-codegen-3.spec.ts:667:7 › cli codegen › should consume contextmenu events, despite a custom context menu @firefox-headed-windows-latest
⚠️ [firefox-library] › tests/library/selector-generator.spec.ts:321:7 › selector generator › should prioritize attributes correctly › placeholder @firefox-headed-windows-latest
⚠️ [firefox-library] › tests/library/trace-viewer.spec.ts:1427:1 › should remove noscript when javaScriptEnabled is set to true @firefox-headed-windows-latest
⚠️ [firefox-library] › tests/library/tracing.spec.ts:312:5 › should overwrite existing file @firefox-headed-windows-latest
⚠️ [firefox-library] › tests/library/video.spec.ts:379:5 › screencast › should capture navigation @firefox-headed-windows-latest
⚠️ [firefox-page] › tests/page/page-evaluate.spec.ts:424:3 › should throw for too deep reference chain @firefox-headed-windows-latest
⚠️ [firefox-library] › tests/library/video.spec.ts:163:5 › screencast › should work with old options @firefox-macos-13-large
⚠️ [firefox-page] › tests/page/page-evaluate.spec.ts:424:3 › should throw for too deep reference chain @firefox-macos-13-large
⚠️ [firefox-library] › tests/library/video.spec.ts:163:5 › screencast › should work with old options @firefox-macos-13-xlarge
⚠️ [firefox-library] › tests/library/video.spec.ts:163:5 › screencast › should work with old options @firefox-macos-14-large
⚠️ [firefox-page] › tests/page/page-evaluate.spec.ts:424:3 › should throw for too deep reference chain @firefox-macos-14-large
⚠️ [firefox-library] › tests/library/video.spec.ts:163:5 › screencast › should work with old options @firefox-macos-14-xlarge
⚠️ [firefox-page] › tests/page/page-evaluate.spec.ts:424:3 › should throw for too deep reference chain @firefox-ubuntu-24.04
⚠️ [firefox-page] › tests/page/page-evaluate.spec.ts:424:3 › should throw for too deep reference chain @firefox-windows-latest
⚠️ [chromium-library] › tests/library/browsercontext-base-url.spec.ts:37:3 › should construct a new URL when a baseURL in browserType.launchPersistentContext is passed to page.goto @msedge-beta-macos-latest
⚠️ [chromium-library] › tests/library/browsercontext-reuse.spec.ts:186:1 › should ignore binding from beforeunload @msedge-beta-macos-latest
⚠️ [chromium-library] › tests/library/browsertype-connect.spec.ts:188:5 › launchServer › should be able to visit ipv6 through localhost @msedge-beta-macos-latest
⚠️ [chromium-library] › tests/library/downloads-path.spec.ts:105:5 › downloads path › should delete downloads when persistent context closes @msedge-beta-macos-latest
⚠️ [chromium-library] › tests/library/inspector/cli-codegen-2.spec.ts:454:7 › cli codegen › should save assets via SIGINT @msedge-beta-macos-latest
⚠️ [chromium-library] › tests/library/inspector/cli-codegen-csharp.spec.ts:171:5 › should work with --save-har @msedge-beta-macos-latest
⚠️ [chromium-library] › tests/library/browsercontext-reuse.spec.ts:30:1 › should re-add binding after reset @msedge-beta-ubuntu-22.04
⚠️ [chromium-library] › tests/library/browsercontext-reuse.spec.ts:30:1 › should re-add binding after reset @msedge-beta-windows-latest
⚠️ [chromium-library] › tests/library/signals.spec.ts:25:5 › should close the browser when the node process closes @msedge-beta-windows-latest
⚠️ [chromium-library] › tests/library/beforeunload.spec.ts:20:3 › should close browser with beforeunload page @msedge-dev-macos-latest
⚠️ [chromium-library] › tests/library/browsercontext-base-url.spec.ts:37:3 › should construct a new URL when a baseURL in browserType.launchPersistentContext is passed to page.goto @msedge-dev-macos-latest
⚠️ [chromium-library] › tests/library/browsercontext-fetch.spec.ts:1231:3 › should work with connectOverCDP @msedge-dev-macos-latest
⚠️ [chromium-library] › tests/library/browsercontext-reuse.spec.ts:206:1 › should reset mouse position @msedge-dev-macos-latest
⚠️ [chromium-library] › tests/library/browsertype-connect.spec.ts:162:5 › launchServer › should be able to visit ipv6 @msedge-dev-macos-latest
⚠️ [chromium-library] › tests/library/headful.spec.ts:252:3 › should click bottom row w/ infobar in OOPIF @msedge-dev-macos-latest
⚠️ [chromium-library] › tests/library/inspector/cli-codegen-2.spec.ts:454:7 › cli codegen › should save assets via SIGINT @msedge-dev-macos-latest
⚠️ [chromium-library] › tests/library/browsercontext-reuse.spec.ts:30:1 › should re-add binding after reset @msedge-dev-ubuntu-22.04
⚠️ [chromium-library] › tests/library/browsercontext-reuse.spec.ts:30:1 › should re-add binding after reset @msedge-macos-latest
⚠️ [chromium-library] › tests/library/browsertype-connect.spec.ts:988:7 › run-server › socks proxy › should check proxy pattern on the client @msedge-macos-latest
⚠️ [chromium-library] › tests/library/inspector/cli-codegen-csharp.spec.ts:171:5 › should work with --save-har @msedge-macos-latest
⚠️ [chromium-library] › tests/library/inspector/cli-codegen-test.spec.ts:88:5 › should not generate recordHAR with --save-har @msedge-macos-latest
⚠️ [chromium-library] › tests/library/browsercontext-reuse.spec.ts:30:1 › should re-add binding after reset @msedge-ubuntu-22.04
⚠️ [chromium-library] › tests/library/client-certificates.spec.ts:400:3 › browser › should not hang on tls errors during TLS 1.2 handshake @tracing-chromium
⚠️ [chromium-library] › tests/library/video.spec.ts:379:5 › screencast › should capture navigation @tracing-chromium-tip-of-tree
⚠️ [firefox-library] › tests/library/page-clock.spec.ts:282:3 › stubTimers › replaces global performance.timeOrigin @tracing-firefox
⚠️ [firefox-page] › tests/page/page-evaluate.spec.ts:424:3 › should throw for too deep reference chain @tracing-firefox
⚠️ [webkit-library] › tests/library/video.spec.ts:475:5 › screencast › should scale frames down to the requested size @tracing-webkit
⚠️ [webkit-page] › tests/page/elementhandle-screenshot.spec.ts:27:5 › element screenshot › should work @tracing-webkit
⚠️ [webkit-page] › tests/page/page-screenshot.spec.ts:345:5 › page screenshot › should work while navigating @tracing-webkit
⚠️ [webkit-page] › tests/page/page-screenshot.spec.ts:565:7 › page screenshot › mask option › should hide elements based on attr @tracing-webkit
⚠️ [webkit-library] › tests/library/inspector/cli-codegen-1.spec.ts:610:7 › cli codegen › should select @webkit-headed-macos-14-xlarge
⚠️ [webkit-library] › tests/library/inspector/cli-codegen-1.spec.ts:268:7 › cli codegen › should fill @webkit-headed-ubuntu-22.04
⚠️ [webkit-library] › tests/library/inspector/cli-codegen-1.spec.ts:461:7 › cli codegen › should record ArrowDown @webkit-headed-ubuntu-24.04
⚠️ [webkit-page] › tests/page/page-click.spec.ts:261:3 › should click on checkbox input and toggle @webkit-headed-ubuntu-24.04
⚠️ [webkit-page] › tests/page/page-leaks.spec.ts:82:5 › click should not leak @webkit-headed-ubuntu-24.04
⚠️ [webkit-library] › tests/library/browsercontext-reuse.spec.ts:206:1 › should reset mouse position @webkit-headed-windows-latest
⚠️ [webkit-library] › tests/library/inspector/cli-codegen-3.spec.ts:488:7 › cli codegen › should generate getByTestId @webkit-headed-windows-latest
⚠️ [webkit-library] › tests/library/inspector/cli-codegen-3.spec.ts:549:7 › cli codegen › should generate getByAltText @webkit-headed-windows-latest
⚠️ [webkit-library] › tests/library/inspector/cli-codegen-3.spec.ts:636:7 › cli codegen › should consume pointer events @webkit-headed-windows-latest
⚠️ [webkit-library] › tests/library/inspector/cli-codegen-3.spec.ts:667:7 › cli codegen › should consume contextmenu events, despite a custom context menu @webkit-headed-windows-latest
⚠️ [webkit-library] › tests/library/inspector/cli-codegen-3.spec.ts:737:7 › cli codegen › should assert value @webkit-headed-windows-latest
⚠️ [webkit-library] › tests/library/inspector/cli-codegen-aria.spec.ts:120:7 › should show aria snapshot error @webkit-headed-windows-latest
⚠️ [webkit-page] › tests/page/page-request-fallback.spec.ts:239:5 › post data › should amend binary post data @webkit-macos-13-large
⚠️ [webkit-library] › tests/library/video.spec.ts:379:5 › screencast › should capture navigation @webkit-macos-14-large
⚠️ [webkit-library] › tests/library/tracing.spec.ts:432:14 › should produce screencast frames crop @webkit-macos-14-xlarge
⚠️ [webkit-library] › tests/library/tracing.spec.ts:432:14 › should produce screencast frames scale @webkit-macos-14-xlarge
⚠️ [webkit-page] › tests/page/page-request-fallback.spec.ts:239:5 › post data › should amend binary post data @webkit-macos-15-large
⚠️ [webkit-page] › tests/page/wheel.spec.ts:101:3 › should dispatch wheel events after popup was opened @smoke @webkit-macos-15-large
⚠️ [webkit-library] › tests/library/inspector/cli-codegen-csharp.spec.ts:227:7 › should work with --save-har and --save-har-glob in nunit @webkit-windows-latest

241352 passed, 9402 skipped
✔️✔️✔️

Merge workflow run.

@dgozman dgozman merged commit 471a28e into microsoft:main Mar 28, 2025
98 of 106 checks passed
dgozman added a commit to dgozman/playwright that referenced this pull request Apr 8, 2025
This reverts commit 471a28e.

Reason: decided to skip an explicit API and instead follow
Node.js attempts to supports HTTP_PROXY and HTTPS_PROXY.
dgozman added a commit to dgozman/playwright that referenced this pull request Apr 10, 2025
Extracted from microsoft#35389. No behavior change whatsoever.
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

Projects

None yet

2 participants