Skip to content

Conversation

ponyfly6
Copy link

@ponyfly6 ponyfly6 commented Sep 2, 2025

Summary

  • Fix network proxy connection issues that occur with OpenAI v5.x library
  • Downgrade OpenAI from v5.x to v4.104.0 for proxy compatibility
  • Add HttpsProxyAgent support for proper proxy configuration
  • Improve error handling and logging for connection issues

Problem

Users behind network proxies (common in enterprise environments or regions like China) experience connection errors when using OpenAI v5.x library. The error manifests as "Connection error" even when proxy settings are correctly configured.

Root Cause

OpenAI v5.x introduced changes to the underlying HTTP client implementation that broke compatibility with proxy configurations, particularly with HttpsProxyAgent.

Solution

  • Version Pinning: Constrain OpenAI to >=4.28.4 <5.0.0 to avoid problematic v5.x versions
  • Proxy Support: Add explicit HttpsProxyAgent configuration for both HTTP and HTTPS agents
  • Error Handling: Enhanced error logging to help diagnose connection issues
  • Backward Compatibility: All existing functionality remains intact

Testing

  • ✅ Local development environment with proxy works correctly
  • ✅ Global installation (npm install -g) works correctly
  • ✅ Network proxy settings are properly applied
  • ✅ All existing functionality preserved
  • ✅ Type checking and build process successful

Impact

This fix enables users in restricted network environments to use the CLI tool successfully, significantly expanding the tool's accessibility.

Related Issues

This addresses the common "Connection error" issue reported by users behind corporate proxies or in regions requiring proxy configurations.

🤖 Generated with Claude Code

- Downgrade OpenAI from v5.x to v4.104.0 to fix proxy compatibility
- Add HttpsProxyAgent support for network proxy configurations
- Update package.json to constrain OpenAI version to <5.0.0
- Improve error handling and logging for connection issues

This resolves the network proxy connection errors that occurred
when using OpenAI v5.x library with proxy configurations.

🤖 Generated with [Claude Code](https://claude.ai/code)

Co-Authored-By: Claude <[email protected]>
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.

1 participant