Replies: 1 comment
|
Your premise checks out, and the chain is exactly three hops. Worth writing out, because it tells you where the fix has to go and it isn't httpx2.
exc_map: ExceptionMapping = {
...
ssl.SSLError: ConnectError,
}
with map_exceptions(exc_map):
...
ssl_stream = await anyio.streams.tls.TLSStream.wrap(...)Then the retry loop catches it ( except (ConnectError, ConnectTimeout):
if retries_left <= 0:
raise
retries_left -= 1The The part that matters for your PR is that httpx2 has no retry loop at all. It forwards the parameter and nothing else ( retries=retries,and its own exception mapping at The good news is that httpcore2 lives in this same repo under A narrow fix works here because for from_exc, to_exc in map.items():
if isinstance(exc, from_exc):
raise to_exc(exc) from excSo putting One practical note, On the urllib3 consistency question, I'd say the shared behaviour comes from the same structural cause in both libraries, |
Uh oh!
There was an error while loading. Please reload this page.
Right now the
retries=behavior will retry a connection in the event of a TLS certificate verification error. Allowing certain transient errors such as SSLEOFError (peer closing mid-handshake) and TLSV1_ALERT_INTERNAL_ERROR (overloaded server) is appropriate, but a failed certificate verification won't change upon retrying.PR #1156 introduces an SSLError exception that could be further subclassed as
CertificateError(SSLError)(mapped to ssl.SSLCertVerificationError), which could then be excluded from retries.To avoid over-representing the impact, only users that opted in to
retries=are affected since it defaults to 0. It's also worth noting thaturllib3has this same behavior so there's probably a discussion about consistency that should be considered, but it seems more accurate to me that retrying the connection should get shortcut to prevent excess connections+handshakes.Happy to take this on if it sounds like something you'd want to implement.
All reactions