Skip to content

fix: preserve timeout deadline provenance - #109

Open
Shubh3819 wants to merge 6 commits into
prooflinedev:mainfrom
Subhrangshu-Chatterjee:fix/windows-wait-deadline-timeout
Open

Shubh3819 wants to merge 6 commits into
prooflinedev:mainfrom
Subhrangshu-Chatterjee:fix/windows-wait-deadline-timeout

Conversation

@Shubh3819

Copy link
Copy Markdown

Summary

Fixes timeout handling in wait_for_review() so that the SDK correctly distinguishes between the caller's overall wait deadline and timeouts occurring inside individual HTTP requests.

Previously, when an HTTP read timed out just before the overall wait deadline, the SDK could incorrectly raise a ProoflineError instead of returning TIMED_OUT. This was particularly noticeable on Windows, where timing precision could make the existing deadline check unreliable.

What changed

1. Track where a timeout comes from

Added explicit timeout provenance to distinguish between:

  • The overall deadline passed to wait_for_review().
  • The internal timeout configured for an individual HTTP request.
  • The HTTP client's connect, read, write, and connection-pool timeouts.

This ensures that only timeouts caused by the caller's deadline are treated as TIMED_OUT. Independent HTTP timeouts continue to raise the appropriate SDK error.

2. Preserve timeout information across the transport layer

Updated the HTTP transport to retain information about which timeout phase was limited by the caller's deadline.

This includes:

  • Mapping connect, read, write, and pool timeout exceptions to their correct types.
  • Applying the deadline limits consistently in synchronous and asynchronous requests.
  • Preserving caller-deadline information when reading streaming response bodies.

3. Preserve HTTP error responses

Ensured that a timeout while reading a response body does not accidentally replace an existing HTTP error.

For example, a 403 response must remain a 403 even if reading its body takes too long. Existing handling of retryable responses such as 429 and 503 is also preserved.

4. Add regression tests

Added tests covering:

  • A read timeout occurring just before the caller's deadline.
  • An internal HTTP timeout occurring before the caller's deadline.
  • Preservation of non-retryable HTTP responses such as 403.
  • Correct timeout behavior during DNS resolution.
  • Both synchronous and asynchronous execution paths.

Validation

  • Full test suite: 222 passed
  • Ruff formatting: passed
  • Ruff lint: passed
  • Mypy: passed (229 source files)
  • git diff --check: passed

Closes #89

@Shubh3819
Shubh3819 force-pushed the fix/windows-wait-deadline-timeout branch from e12607e to 88b7969 Compare November 27, 2026 09:19

This branch has not been deployed

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

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

On Windows, wait_for_review sometimes raises a timeout error instead of returning TIMED_OUT

1 participant