Conversation
…647) niquests uses lazy HTTP/2 response gathering: accessing r.status_code or r.headers can raise ConnectionError if the underlying connection has gone stale. This produces a confusing nested-exception traceback and an intermittent failure for callers (c.events(), etc.). Changes: - Add DAVNetworkError(DAVError) to caldav/lib/error.py to represent network-level failures wrapping the underlying library exception. - In DAVClient._sync_request(), wrap the session.request() call and all subsequent response-attribute access in a try/except that catches requests.exceptions.ConnectionError and requests.exceptions.Timeout, re-raising as DAVNetworkError. - In DAVClient.request(), catch DAVNetworkError and retry once for idempotent methods (GET, HEAD, OPTIONS, PROPFIND, REPORT, PUT, DELETE, MKCOL, MKCALENDAR). POST is the only non-idempotent method and is not retried. - Apply the same pattern to AsyncDAVClient._async_request() using an outer try/except around the existing auth-workaround try/except, with a _connection_retried flag to prevent infinite loops. The retry transparently recovers from stale HTTP/2 connection reuse, which is the root cause of the "sometimes works, sometimes times out" symptom. Ref: #647 Co-Authored-By: Claude Sonnet 4.6 <noreply@anthropic.com>
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.
This commit was done by Claude and hasn't been thoroughly reviewed yet. The code should be safe to run, but I'm wondering if this is the right way of fixing the problem. Pull request is in "draft mode" as for now.
niquests uses lazy HTTP/2 response gathering: accessing r.status_code or
r.headers can raise ConnectionError if the underlying connection has gone
stale. This produces a confusing nested-exception traceback and an
intermittent failure for callers (c.events(), etc.).
Changes:
network-level failures wrapping the underlying library exception.
subsequent response-attribute access in a try/except that catches
requests.exceptions.ConnectionError and requests.exceptions.Timeout,
re-raising as DAVNetworkError.
idempotent methods (GET, HEAD, OPTIONS, PROPFIND, REPORT, PUT, DELETE,
MKCOL, MKCALENDAR). POST is the only non-idempotent method and is not
retried.
outer try/except around the existing auth-workaround try/except, with
a _connection_retried flag to prevent infinite loops.
The retry transparently recovers from stale HTTP/2 connection reuse, which
is the root cause of the "sometimes works, sometimes times out" symptom.
Ref: #647
Co-Authored-By: Claude Sonnet 4.6 noreply@anthropic.com