fix: Stop polling an action attempt once the timeout passes - #1004
Open
razor-x wants to merge 3 commits into
Open
fix: Stop polling an action attempt once the timeout passes#1004razor-x wants to merge 3 commits into
razor-x wants to merge 3 commits into
Conversation
Waiting for an action attempt raced an unbounded poll loop against a timer. The caller received SeamActionAttemptTimeoutError, but the losing poll loop was never cancelled and kept polling once per interval forever. The race also let a timeout shorter than the polling interval reject without ever polling, and a pollingInterval of zero polled unthrottled for the entire timeout window. Poll iteratively against a deadline instead: sleep the lesser of the polling interval and the remaining budget, poll, and time out only once the deadline has passed, so every wait polls at least once and polling stops with the wait. Validate the options up front, raising SeamHttpInvalidOptionsError for a negative timeout or a pollingInterval not greater than zero, and fix the timeout error message which read 'waiting for action action attempt'. Co-Authored-By: Claude <noreply@anthropic.com> Claude-Session: https://claude.ai/code/session_01B8xeJm2Hd923k8uo6eoFd2
…x115l-h3-poll-deadline
Co-Authored-By: Claude <noreply@anthropic.com> Claude-Session: https://claude.ai/code/session_01B8xeJm2Hd923k8uo6eoFd2
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.
Problem
SDK audit finding H3 (high, runtime-verified):
resolveActionAttemptraced an unbounded poll recursion against a timer.Promise.racerejected the caller withSeamActionAttemptTimeoutErrorbut never cancelled the losing poll loop:Each timed-out wait on a pending attempt left an immortal loop polling once per interval forever, pinning the Node event loop open. Related defects in the same code: a timeout shorter than the polling interval rejected without ever polling;
pollingInterval: 0polled unthrottled for the whole window; and the timeout message read "waiting for action action attempt".Fix
Poll iteratively against a deadline (mirroring seamapi/php#465): sleep
min(pollingInterval, remaining), poll, and time out only once the deadline has actually passed — so every wait polls at least once and no orphan loop survives the error. Validate options up front with the existingSeamHttpInvalidOptionsError: negativetimeoutand non-positivepollingIntervalare rejected. Fixed the error message typo and documented the semantics in the README.Tests
timeout: 300, pollingInterval: 60000→ exactly one poll, rejects in ~300ms (old code: zero polls)timeout: -1andpollingInterval: 0→SeamHttpInvalidOptionsErrorwith pinned messagesVerified per the audit-notes recipe: all 4 new tests fail on the reverted source with the audit's exact symptoms. Full suite (129 tests), lint, typecheck green.
Part of applying the rev-3 SDK audit (one PR per finding). Related: #1002, #1003.
🤖 Generated with Claude Code
https://claude.ai/code/session_01B8xeJm2Hd923k8uo6eoFd2
Generated by Claude Code