Skip to content

[WIP] Fix connection issue with uvloop and SOCKS5#12

Merged
xrh0905 merged 2 commits into
edgefrom
copilot/fix-uvloop-socks5-connection
Dec 9, 2025
Merged

[WIP] Fix connection issue with uvloop and SOCKS5#12
xrh0905 merged 2 commits into
edgefrom
copilot/fix-uvloop-socks5-connection

Conversation

Copy link
Copy Markdown

Copilot AI commented Dec 9, 2025

Fix uvloop + SOCKS5 Connectivity Issue

Analysis

  • Understand the issue: uvloop is incompatible with SOCKS5 socket monkey-patching
  • Determine solution: Disable uvloop when SOCKS5 is configured
  • Implement fix in try_setup_uvloop() to check for SOCKS5 configuration
  • Update documentation to reflect the incompatibility
  • Test the fix manually
  • Run code review
  • Run security checks

Root Cause

The issue occurs because:

  1. apply_upstream_proxy_settings() patches socket.socket with socks.socksocket
  2. try_setup_uvloop() is called afterwards and sets up uvloop's event loop
  3. uvloop's native socket implementation conflicts with the monkey-patched SOCKS socket
  4. This causes connection failures when both features are enabled

Solution

Modified try_setup_uvloop() to detect SOCKS5 configuration and skip uvloop setup when SOCKS5 is active. When SOCKS5 is detected, a clear message is printed: "SOCKS5 proxy is configured, skipping uvloop (incompatible)"

Original prompt

This section details on the original issue you should resolve

<issue_title>Fix unable to connect when using uvloop with socks5. If unfixable, disable uvloop when SOCKS5.</issue_title>
<issue_description></issue_description>

Comments on the Issue (you are @copilot in this section)


💬 We'd love your input! Share your thoughts on Copilot coding agent in our 2 minute survey.

…s configured

Co-authored-by: xrh0905 <29017419+xrh0905@users.noreply.github.com>
@xrh0905 xrh0905 marked this pull request as ready for review December 9, 2025 16:25
Copilot AI review requested due to automatic review settings December 9, 2025 16:25
Copy link
Copy Markdown

Copilot AI left a comment

Choose a reason for hiding this comment

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

Pull request overview

This PR fixes a critical incompatibility issue between uvloop and SOCKS5 proxy configuration. The root cause is that SOCKS5 implementation monkey-patches socket.socket with socks.socksocket, which conflicts with uvloop's native socket implementation, causing connection failures when both features are enabled simultaneously.

Key Changes:

  • Added a pre-check in try_setup_uvloop() to detect SOCKS5 configuration before setting up uvloop
  • When SOCKS5 is active, uvloop setup is skipped with an informative error message

💡 Add Copilot custom instructions for smarter, more guided reviews. Learn how to get started.

@xrh0905 xrh0905 merged commit 3c19b93 into edge Dec 9, 2025
7 checks passed
Copilot AI requested a review from xrh0905 December 9, 2025 16:29
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.

Fix unable to connect when using uvloop with socks5. If unfixable, disable uvloop when SOCKS5.

3 participants