Repository navigation
Fall back to the next address when one silently drops connections - #99
Open
khanak0509 wants to merge 5 commits into
Open
khanak0509 wants to merge 5 commits into
khanak0509 wants to merge 5 commits into
Conversation
This branch has not been deployed
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
Problem
ProoflineClientresolves the host itself and tries each address in turn, but all attempts shareone deadline. If the first address silently drops the SYN (broken IPv6, or a dead node behind
round-robin DNS), that attempt uses up the whole timeout, the next address is never tried, and the
call fails with
urn:proofline:sdk:timeout.proofline.shhas two AAAA and two A records, and dual-stack hosts try IPv6 first. So on a networkwith broken IPv6, every sync call fails, while
AsyncProoflineClient(anyio Happy Eyeballs) andstock httpx recover. Fast failures such as "connection refused" already fell back correctly.
Approach
RFC 8305-style racing in
NetworkBackend.connect_tcp, only when a name has more than one address:Each attempt still goes through
httpcore2.SyncBackend.connect_tcp, so socket options, scopedIPv6 and error mapping are unchanged. Single-address hosts and IP literals keep the old path.
Verification
python3 scripts/check.pypasses, on Python 3.11 and 3.13.tests/test_sync_connect.py: 19 tests covering fallback, deadlines, cleanup and ordering.Each fix from the review below has a test that fails without it.
maintimed out after 5.00 s; thisbranch connected in about 0.8 s.
Repro script (run from the repository root)
Proofline review
I ran Proofline on this change in my own organization
(nines-lab/sdk-python#1), over four rounds.
I reproduced each finding with a failing test or a mutation before changing anything.
ConnectErrorcould replace the deadline timeoutI stopped after the fourth round. Proofline had confirmed the earlier fixes, and the remaining
findings were narrow scheduling edge cases.