Skip to content

Conversation

Skn0tt
Copy link
Member

@Skn0tt Skn0tt commented Oct 6, 2025

closes #37676

This comment has been minimized.

@Skn0tt Skn0tt marked this pull request as ready for review October 6, 2025 10:04
@Skn0tt Skn0tt self-assigned this Oct 6, 2025
@Skn0tt Skn0tt requested a review from dgozman October 6, 2025 10:04

This comment has been minimized.

if (proxy.username)
proxyOpts.auth = `${proxy.username}:${proxy.password || ''}`;

if (forUrl && ['ws:', 'wss:'].includes(forUrl.protocol)) {
Copy link
Contributor

Choose a reason for hiding this comment

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

  • Why removing all this code? It looks valuable to me, with all the comments and TODOs.
  • It does not look like url.format() understands auth property, does it?

Copy link
Member Author

Choose a reason for hiding this comment

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

(parsedProxyURL as any).secureProxy = parsedProxyURL.protocol === 'https:';

options.agent = new HttpsProxyAgent(parsedProxyURL);
options.agent = new HttpsProxyAgent(url.format(parsedProxyURL));
Copy link
Contributor

Choose a reason for hiding this comment

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

  • I'm not sure url.format() understands secureProxy option.
  • Shall we switch to new URL(proxyURL) instead of parse() + format()?

Copy link
Member Author

Choose a reason for hiding this comment

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

  • I'm not sure why we had secureProxy here, in the first place. It got removed in a recent dependency update, but even before it doesn't make sense how we pass it here. See TooTallNate/proxy-agents@b3860aa. let me remove it.
  • I'll try that in a separate PR.

Copy link
Contributor

Choose a reason for hiding this comment

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

I think the linked commit removes it from the agent, not from the input url. That said, I can't find any usage of secureProxy in the package...

Copy link
Member Author

Choose a reason for hiding this comment

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

Which is why I don't understand why we had this in the first place.

Copy link
Member Author

@Skn0tt Skn0tt Oct 7, 2025

Choose a reason for hiding this comment

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

Ahh, this is where it was read! The old version of the library was in a different repository. https://github.com/TooTallNate/node-http-proxy-agent/blob/5368fa899134a9b0d7d49cc6917c1eecabe7aeb0/src/agent.ts#L54


This project incorporates components from the projects listed below. The original copyright notices and the licenses under which Microsoft received such components are set forth below. Microsoft reserves all rights not expressly granted herein, whether by implication, estoppel or otherwise.

- [email protected] (https://github.com/TooTallNate/node-agent-base)
Copy link
Contributor

Choose a reason for hiding this comment

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

Let's make sure we update socks proxy agent as well.

Copy link
Member Author

Choose a reason for hiding this comment

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

I'll do that in a separate PR.

Copy link
Member Author

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

Both the change from url.format to WHATWG URL (it throws on irregular inputs, whereas the current one returns null fields), and the socks update have a far higher potential for regression than the HTTPS Proxy update.

I'll work on those in separate PRs that we can revert individually, and keep this one solely about the ALPN issue at hand.

I've added a nifty little regression test to this PR.

(parsedProxyURL as any).secureProxy = parsedProxyURL.protocol === 'https:';

options.agent = new HttpsProxyAgent(parsedProxyURL);
options.agent = new HttpsProxyAgent(url.format(parsedProxyURL));
Copy link
Member Author

Choose a reason for hiding this comment

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

  • I'm not sure why we had secureProxy here, in the first place. It got removed in a recent dependency update, but even before it doesn't make sense how we pass it here. See TooTallNate/proxy-agents@b3860aa. let me remove it.
  • I'll try that in a separate PR.

if (proxy.username)
proxyOpts.auth = `${proxy.username}:${proxy.password || ''}`;

if (forUrl && ['ws:', 'wss:'].includes(forUrl.protocol)) {
Copy link
Member Author

Choose a reason for hiding this comment

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


This project incorporates components from the projects listed below. The original copyright notices and the licenses under which Microsoft received such components are set forth below. Microsoft reserves all rights not expressly granted herein, whether by implication, estoppel or otherwise.

- [email protected] (https://github.com/TooTallNate/node-agent-base)
Copy link
Member Author

Choose a reason for hiding this comment

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

I'll do that in a separate PR.

@Skn0tt Skn0tt requested a review from dgozman October 6, 2025 13:15

This comment has been minimized.

this._serverEncrypted = await proxyAgent.callback(new EventEmitter() as any, { host: rewriteToLocalhostIfNeeded(this.host), port: this.port, secureEndpoint: false });
else
if (proxyAgent) {
if ('callback' in proxyAgent)
Copy link
Contributor

Choose a reason for hiding this comment

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

Do we have callback vs connect due to different versions of socks vs https? If so, let's not forget to clean things up later.

Copy link
Member Author

@Skn0tt Skn0tt Oct 6, 2025

Choose a reason for hiding this comment

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

yup, it's because of different versions. I don't see us forgetting - any update to SOCKS will require it to also move to connect, at that point we'll be cleaning up.

This comment has been minimized.

Copy link
Contributor

github-actions bot commented Oct 6, 2025

Test results for "tests 1"

6 flaky ⚠️ [chromium-library] › library/popup.spec.ts:258 › should not throw when click closes popup `@chromium-ubuntu-22.04-node18`
⚠️ [firefox-library] › library/inspector/cli-codegen-1.spec.ts:1079 › cli codegen › should not throw csp directive violation errors `@firefox-ubuntu-22.04-node18`
⚠️ [firefox-page] › page/page-goto.spec.ts:83 › should work with Cross-Origin-Opener-Policy `@firefox-ubuntu-22.04-node18`
⚠️ [playwright-test] › ui-mode-trace.spec.ts:397 › should work behind reverse proxy `@macos-latest-node18-1`
⚠️ [chromium-library] › library/proxy.spec.ts:326 › should use http proxy for websocket requests `@ubuntu-22.04-chromium-tip-of-tree`
⚠️ [chromium] › headerView.spec.tsx:49 › should toggle filters `@web-components-html-reporter`

46922 passed, 816 skipped


Merge workflow run.

@Skn0tt Skn0tt merged commit 3270ee6 into main Oct 6, 2025
34 of 35 checks passed
@Skn0tt Skn0tt deleted the update-https-proxy-agent branch October 6, 2025 15:40
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.

[Bug]: Invalid ALPN protocol identifier in https-proxy-agent

2 participants