Include 'timed out' messages in async network timeout exceptions - #1161
Include 'timed out' messages in async network timeout exceptions#1161Kludex wants to merge 5 commits into
Conversation
|
Docs preview: https://7c6a7ee0-httpx2-docs.pydantic.workers.dev |
Merging this PR will not alter performance
Comparing Footnotes
|
There was a problem hiding this comment.
1 issue found across 3 files (changes from recent commits).
Prompt for AI agents (unresolved issues)
Check if these issues are valid — if so, understand the root cause of each and fix them. If appropriate, use sub-agents to investigate and fix each issue separately.
<file name="src/httpcore2/httpcore2/_backends/anyio.py">
<violation number="1" location="src/httpcore2/httpcore2/_backends/anyio.py:41">
P3: The fix only adds the "timed out" message to ReadTimeout, so async write/connect/pool timeouts remain inconsistent with sync. The same files still map TimeoutError/trio.TooSlowError to WriteTimeout (anyio.py write, line 48) and ConnectTimeout (anyio.py start_tls/connect_tcp/connect_unix_socket, trio.py equivalents) through map_exceptions, which passes the empty str(exc) as the message, while the sync backend's socket.timeout carries "timed out". If the goal is sync/async consistency for timeout messages, these paths need the same treatment (or the removal of the _exceptions.py 'timed out' handling should be reconsidered so it applies to all TimeoutException subclasses).</violation>
</file>
Reply with feedback, questions, or to request a fix.
Re-trigger cubic
There was a problem hiding this comment.
All reported issues were addressed across 4 files (changes from recent commits).
Tip: Review your code locally with the cubic CLI to iterate faster.
Re-trigger cubic
|
Closing as not planned. The exception type already identifies the timeout, and adding a synthetic message does not provide enough value to justify the additional mapping complexity. |
Closes #742.
AnyIO and Trio raise network timeout exceptions without messages. Map async read, write, and connect timeouts with explicit factories so they report
timed out, matching the sync socket backend.The generic exception mapper remains policy-free. Its mapping values now accept exception factories, allowing each backend to control the resulting exception message.
Pool timeouts are unchanged because they originate from connection-pool synchronization rather than a socket timeout, and both sync and async pool timeouts already have the same behavior.
AI Disclaimer
This PR was developed with the assistance of either Claude or Codex. I've reviewed and verified the changes.