Skip to content

fix(client): treat timeout errors near deadline as TIMED_OUT on Windows - #100

Open
P1Manav wants to merge 1 commit into
prooflinedev:mainfrom
P1Manav:fix-windows-wait-for-review-timeout-89
Open

P1Manav wants to merge 1 commit into
prooflinedev:mainfrom
P1Manav:fix-windows-wait-for-review-timeout-89

Conversation

@P1Manav

@P1Manav P1Manav commented Nov 24, 2026

Copy link
Copy Markdown

Summary

Fixes #89

On Windows, socket timeouts scheduled via OS socket mechanisms can trigger slightly before the monotonic deadline ticks over due to the Windows timer resolution (~15.6 ms). When this happens during wait_for_review, the socket read expires with ProoflineError(0, "urn:proofline:sdk:timeout"), but _transport.remaining() still returns a tiny positive duration, causing wait_for_review to raise ProoflineError rather than returning TIMED_OUT.

Changes

  • Introduced _DEADLINE_TOLERANCE_SECONDS = 0.025 in proofline/client.py.
  • Updated wait_for_review (in both ProoflineClient and AsyncProoflineClient) to break and return TIMED_OUT when a timeout error occurs and remaining() <= _DEADLINE_TOLERANCE_SECONDS.
  • Added unit tests in tests/test_http.py (test_wait_for_review_tolerates_early_socket_timeout_jitter) verifying:
    • Timeouts within deadline tolerance return TIMED_OUT.
    • Timeouts with substantial remaining time (> tolerance) are still re-raised.

Verification

  • ruff check proofline tests — all checks passed
  • ruff format --check proofline tests — all formatted
  • mypy proofline — 0 issues
  • pytest — 220 passed in 30.64s

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