fix: Stop polling an action attempt once the timeout passes - #635
Open
razor-x wants to merge 2 commits into
Open
fix: Stop polling an action attempt once the timeout passes#635razor-x wants to merge 2 commits into
razor-x wants to merge 2 commits into
Conversation
Co-Authored-By: Claude Fable 5 <noreply@anthropic.com> Claude-Session: https://claude.ai/code/session_01Y1RzepycXEYA3LStfjt8cY
…it-o2iid9-02-poll-deadline
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.
What
Rewrites
poll_until_ready/poll_until_ready_asyncaround a monotonic deadline (SDK audit finding H2; ports the JS #1004 / PHP #465 fix):timeout < 0andpolling_interval <= 0(including NaN) raiseSeamInvalidOptionsErrorwith the same messages as the JS SDK, instead of looping forever or leaking aValueErrorout oftime.sleep.polling_interval, sopolling_interval=0never timed out (audit reproduced 1,915 unthrottled polls in 3s) and HTTP round-trip time was excluded entirely — a "5 second" timeout could block for minutes.min(polling_interval, remaining): the wait no longer overruns its timeout by a full interval (timeout=0.5, polling_interval=5previously slept 5s), and it always polls at least once even whentimeout < polling_interval.resolve_action_attemptnow seeds the poll with the attempt it just received, so an already-resolved attempt no longer costs an extra/action_attempts/getround trip (same as JS/PHP).Both the sync and async variants carried identical bugs; both are fixed identically.
Testing
New tests (sync + async, pinned messages): zero and negative
polling_intervalraise, negativetimeoutraises, atimeout < polling_intervalwait still polls exactly once (request-count asserted via a recording server) and finishes near the deadline. The existing interval-overrun test now asserts elapsed time, which it previously did not.Verified per the audit-fix recipe: with
seam/modules/action_attempts.pyreverted to main, the new tests fail with the audit's exact symptoms (5s sleep on a 0.5s timeout; a negative timeout surfacing asSeamActionAttemptTimeoutError: Timed out ... after -1s).Full suite: 191 passed. mypy, pylint (10.00), black all clean.
🤖 Generated with Claude Code
https://claude.ai/code/session_01Y1RzepycXEYA3LStfjt8cY
Generated by Claude Code