Skip to content
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

Proxy Support seems to be broken #1345

Open
madsteer opened this issue Jan 16, 2025 · 0 comments
Open

Proxy Support seems to be broken #1345

madsteer opened this issue Jan 16, 2025 · 0 comments

Comments

@madsteer
Copy link

  • REST Client Version: 0.25.1
  • VSCode Version: 1.96.3
  • OS Version: macOs 15.2 Sequoia

Steps to Reproduce:

  1. configure http.*proxy* settings in VSCode user settings
  2. configure "rest-client.excludeHostsForProxy" setting in VSCode user settings
  3. open a *.rest file to edit in vscode and put
     ### google test
     GET https://www.google.com
    in it.
  4. Launch vscode-restclient in debug mode
  5. run google test
  6. error message is "Expected the options.agentproperties to behttp, httpsorhttp2, got _events"

I tried modifying the proxy code in src/utils/httpClient.ts like so

       // set proxy
        if (settings.proxy && !HttpClient.ignoreProxy(httpRequest.url, settings.excludeHostsForProxy)) {
            const proxyEndpoint = url.parse(settings.proxy);
            if (/^https?:$/.test(proxyEndpoint.protocol || '')) {
                // const proxyOptions = {
                //     host: proxyEndpoint.hostname,
                //     port: Number(proxyEndpoint.port),
                //     rejectUnauthorized: settings.proxyStrictSSL
                // };

                const ctor = (httpRequest.url.startsWith('http:')
                    ? await import('http-proxy-agent')
                    : await import('https-proxy-agent')).default;

                const http = new ctor({
                    keepAlive: true,
                    keepAliveMsecs: 1000,
                    maxSockets: 256,
                    maxFreeSockets: 256,
                    scheduling: 'lifo',
                    proxy: 'http://10.1.2.3.1:8080'
                })

                options.agent = { http }
                // options.agent = new ctor(proxyOptions);
            }
        }

        return options;

because it seemed more like how got version 11.8.6 wants it to be configured. That changed the error message to "The \"listener\" argument must be of type function. Received an instance of Object".

I saw some other issues suggesting that maybe it's a Node version issue. I was running node 20.18.0, so I backed it off to 16.2.0 but that didn't have any affect.

I saw another issue suggesting maybe it was some kind of IPv6 problem so I added "--dns-result-order=ipv4first" to the "args" array in launch.json. That didn't seem to affect it either.

I'm happy to do more testing, but I'm at a loss as to how to fix.

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

No branches or pull requests

1 participant