diff --git a/README.md b/README.md index 1b5e8fe2ecd..a0cd4b83a62 100644 --- a/README.md +++ b/README.md @@ -105,6 +105,7 @@ Make Roo Code work your way with: - [Custom Modes](https://docs.roocode.com/advanced-usage/custom-modes) for specialized tasks - [Local Models](https://docs.roocode.com/advanced-usage/local-models) for offline use - [Auto-Approval Settings](https://docs.roocode.com/advanced-usage/auto-approving-actions) for faster workflows +- [Proxy Configuration](docs/PROXY_CONFIGURATION.md) for working with corporate proxies and VPNs ## Resources diff --git a/docs/PROXY_CONFIGURATION.md b/docs/PROXY_CONFIGURATION.md new file mode 100644 index 00000000000..01ab3c02296 --- /dev/null +++ b/docs/PROXY_CONFIGURATION.md @@ -0,0 +1,100 @@ +# Proxy Configuration Guide + +## Issue: Connection Errors with Proxy Settings + +If you're experiencing "Connection error" messages when using Roo Code with a proxy (SOCKS5, HTTP proxy, or PAC file), this guide will help you resolve the issue. + +## Problem + +When VSCode is configured to use a proxy (via environment variables, settings, or command-line arguments), but the `http.electronFetch` setting is disabled (which is the default), the extension may fail to connect to API endpoints. This particularly affects: + +- OpenAI API connections +- OpenAI-compatible API providers +- Other providers that use the native `fetch` API + +## Symptoms + +- Generic "Connection error" messages when trying to use the extension +- Models populate correctly but chat completions fail +- Network Logger shows requests but they don't reach the server +- The same configuration works in other extensions (like Cline) + +## Solution + +### Option 1: Enable Electron Fetch (Recommended) + +1. Open VSCode Settings (`Cmd/Ctrl + ,`) +2. Search for `http.electronFetch` +3. Check the box to enable the setting +4. Restart VSCode +5. Try using Roo Code again + +### Option 2: Use Command Line + +Add this to your VSCode settings.json: + +```json +{ + "http.electronFetch": true +} +``` + +### Option 3: Configure VSCode Launch + +If you're launching VSCode with a PAC file, ensure both settings are configured: + +```bash +code --proxy-pac-url=http://localhost:8000/proxy.pac +``` + +And enable `http.electronFetch` in settings. + +## Why This Happens + +VSCode has two different implementations for making HTTP requests: + +1. **Node.js fetch** (default): Doesn't fully support all proxy configurations +2. **Electron fetch**: Better proxy support but disabled by default + +When `http.electronFetch` is `false` (default), extensions using the native fetch API may fail to route requests through your proxy correctly. + +## Supported Proxy Types + +With `http.electronFetch` enabled, the following proxy configurations are supported: + +- HTTP/HTTPS proxies (via `http.proxy` setting or environment variables) +- SOCKS5 proxies +- PAC (Proxy Auto-Configuration) files +- Environment variables: `HTTP_PROXY`, `HTTPS_PROXY`, `ALL_PROXY` + +## Troubleshooting + +If you're still experiencing issues after enabling `http.electronFetch`: + +1. **Verify proxy settings**: Ensure your proxy configuration is correct +2. **Check firewall rules**: Make sure VSCode is allowed through your firewall +3. **Test connectivity**: Try accessing the API endpoint directly via curl or browser +4. **Check API credentials**: Ensure your API keys are valid and have the necessary permissions +5. **Review logs**: Check the Roo Code output channel for detailed error messages + +## Alternative Solutions + +If enabling `http.electronFetch` doesn't resolve your issue: + +1. **Temporarily disable proxy**: If the proxy isn't required for the API endpoint +2. **Use a different provider**: Some providers may work better with your proxy setup +3. **Configure proxy exceptions**: Add API endpoints to your proxy bypass list + +## Related Issues + +- [VSCode Issue #12588](https://github.com/microsoft/vscode/issues/12588) - Original discussion about proxy support +- [Roo Code Issue #6991](https://github.com/RooCodeInc/Roo-Code/issues/6991) - Specific issue about connection errors with proxies + +## Need Help? + +If you're still experiencing issues, please: + +1. Open an issue on [GitHub](https://github.com/RooCodeInc/Roo-Code/issues) +2. Include your proxy configuration (without sensitive information) +3. Provide the error messages from the Roo Code output channel +4. Mention whether `http.electronFetch` is enabled diff --git a/src/core/task/Task.ts b/src/core/task/Task.ts index 2103dacb274..d349de3ee4b 100644 --- a/src/core/task/Task.ts +++ b/src/core/task/Task.ts @@ -2221,10 +2221,19 @@ export class Task extends EventEmitter implements TaskLike { return } else { - const { response } = await this.ask( - "api_req_failed", - error.message ?? JSON.stringify(serializeError(error), null, 2), - ) + let errorMsg = error.message || "API request failed" + + // Add helpful message about proxy configuration if relevant + if ( + errorMsg.includes("ECONNREFUSED") || + errorMsg.includes("ETIMEDOUT") || + errorMsg.includes("ENOTFOUND") + ) { + errorMsg += + "\n\nIf you're behind a proxy, try enabling the 'http.electronFetch' setting in VSCode:\n1. Open Settings (Cmd/Ctrl + ,)\n2. Search for 'http.electronFetch'\n3. Enable the setting\n4. Restart VSCode" + } + + const { response } = await this.ask("api_req_failed", errorMsg) if (response !== "yesButtonClicked") { // This will never happen since if noButtonClicked, we will