Skip to content

fix(curl-impersonate): treat a refused CONNECT tunnel as a proxy error - #2109

Open
vdusek wants to merge 2 commits into
masterfrom
fix/curl-connect-tunnel-proxy-error
Open

fix(curl-impersonate): treat a refused CONNECT tunnel as a proxy error#2109
vdusek wants to merge 2 commits into
masterfrom
fix/curl-connect-tunnel-proxy-error

Conversation

@vdusek

@vdusek vdusek commented Aug 3, 2026

Copy link
Copy Markdown
Collaborator

curl-cffi 0.16.0 broke two things in CurlImpersonateHttpClient, which is why #2107 capped it. This fixes both and drops the cap.

  1. Bundled libcurl went 8.15.0 -> 8.21.0, so a refused CONNECT tunnel is now CURLE_COULDNT_CONNECT with CONNECT tunnel failed instead of CURLE_RECV_ERROR. curl_cffi maps only the latter to CurlProxyError, so _is_proxy_error stopped recognizing it and sessions were not rotated. The needle lives in _curl_impersonate.py rather than the shared ROTATE_PROXY_ERRORS, which mirrors the JS Crawlee list - impit and httpx never produce libcurl messages.

  2. The session cookie write path moved to Cookies.update_cookies_from_curl_changes, leaving the _EmptyCookies override inert. Isolation held (get_cookies_for_curl is still overridden, so nothing was ever sent), but every response cookie accumulated in the jar of the per-proxy session cached for the client's lifetime. Measured with the same 25-request repro: 25 cookies on 0.16.0, 0 on 0.15.0.

The existing test_crawl_with_proxy_disabled[curl] and test_send_request_with_proxy_disabled[curl] cover the first; test_internal_session_cookie_jar_stays_empty is new for the second.

Closes: #2111

✍️ Drafted by Claude Code

@vdusek vdusek added the t-tooling Issues with this label are in the ownership of the tooling team. label Aug 3, 2026
@vdusek vdusek self-assigned this Aug 3, 2026
@github-actions github-actions Bot added this to the 146th sprint - Tooling team milestone Aug 3, 2026
@vdusek vdusek changed the title fix: treat a refused CONNECT tunnel as a proxy error in the curl client fix(curl-impersonate): treat a refused CONNECT tunnel as a proxy error Aug 3, 2026
@vdusek vdusek added the bug Something isn't working. label Aug 3, 2026
@codecov

codecov Bot commented Aug 3, 2026

Copy link
Copy Markdown

Codecov Report

✅ All modified and coverable lines are covered by tests.
✅ Project coverage is 93.56%. Comparing base (463806f) to head (67d4f4b).
⚠️ Report is 2 commits behind head on master.

Additional details and impacted files
@@           Coverage Diff           @@
##           master    #2109   +/-   ##
=======================================
  Coverage   93.55%   93.56%           
=======================================
  Files         181      181           
  Lines       12590    12595    +5     
=======================================
+ Hits        11779    11784    +5     
  Misses        811      811           
Flag Coverage Δ
unit 93.56% <100.00%> (+<0.01%) ⬆️

Flags with carried forward coverage won't be shown. Click here to find out more.

☔ View full report in Codecov by Harness.
📢 Have feedback on the report? Share it here.

🚀 New features to boost your workflow:
  • ❄️ Test Analytics: Detect flaky tests, report on failures, and find test suite problems.
  • 📦 JS Bundle Analysis: Save yourself from yourself by tracking and limiting bundle sizes in JS merges.

@vdusek vdusek added the adhoc Ad-hoc unplanned task added during the sprint. label Aug 3, 2026
@github-actions github-actions Bot added the tested Temporary label used only programatically for some analytics. label Aug 3, 2026
@vdusek
vdusek marked this pull request as ready for review August 3, 2026 09:03
@vdusek vdusek changed the title fix(curl-impersonate): treat a refused CONNECT tunnel as a proxy error fix(curl-impersonate): support curl-cffi 0.16.0 Aug 3, 2026
@vdusek
vdusek requested a review from janbuchar August 3, 2026 09:55
@vdusek vdusek changed the title fix(curl-impersonate): support curl-cffi 0.16.0 fix(curl-impersonate): treat a refused CONNECT tunnel as a proxy error Aug 3, 2026

@Mantisus Mantisus left a comment

Copy link
Copy Markdown
Collaborator

Choose a reason for hiding this comment

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

LGTM

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

adhoc Ad-hoc unplanned task added during the sprint. bug Something isn't working. t-tooling Issues with this label are in the ownership of the tooling team. tested Temporary label used only programatically for some analytics.

Projects

None yet

Development

Successfully merging this pull request may close these issues.

Proxy errors are not detected with curl-cffi 0.16.0

3 participants