Skip to content

fix: stop polling sleeps at the remaining deadline - #283

Open
ch-z-hc wants to merge 1 commit into
MiniMax-AI:mainfrom
ch-z-hc:fix/poll-deadline-sleep
Open

ch-z-hc wants to merge 1 commit into
MiniMax-AI:mainfrom
ch-z-hc:fix/poll-deadline-sleep

Conversation

@ch-z-hc

@ch-z-hc ch-z-hc commented Oct 13, 2026 •

Copy link
Copy Markdown

When a pending task is near its polling deadline, poll() still sleeps for the entire configured interval. For example, a 50 ms timeout with a 1.5 s interval takes about 1.5 s to report Polling timed out. The CLI's default video polling interval is 5 s, so short timeouts can substantially overrun while waiting between requests.

Cap that sleep by the time remaining before the existing deadline. This is limited to the interval between requests: it does not change HTTP request timeouts or how completed and failed task responses are handled.

The regression fails on unchanged source (about 1504 ms) and passes with the one-line fix (about 51 ms). A separate real HTTP check against a local pending-task server took about 1543 ms on unmodified upstream and 54 ms with the patch, with one request in both cases.

Validation with Bun 1.4.0:

  • Polling suite: 6 passed on Windows; typecheck and lint passed on Windows and Linux. Lint retains one existing warning in test/sdk/speech.test.ts.
  • Linux production build and CI-style compiled CLI version smoke test passed.
  • Full Linux suite: 597 passed, 3 failed. Unmodified a965e72 produces the same 3 failures (596 passed): two region-detection/auth tests exceed their existing 5 s test timeouts, and a FileSDK upload assertion sees a loopback base URL instead of the global endpoint. A second run with process-local loopback proxy bypass had 596 passed and 4 failed, adding an existing ImageSDK validation/network test timeout; that extra timeout is not diagnosed here. The full suite is not green. No tests were skipped or timeouts/assertions relaxed. OAuth tests used a temporary process-local no-op xdg-open to prevent launching a real browser; source and tests were otherwise unchanged.
  • Two independent automated blind reviews found no actionable issues.

Codex assisted with investigation, implementation, testing and the automated reviews. These reviews are not independent human code review.

@ch-z-hc
ch-z-hc marked this pull request as ready for review October 14, 2026 08:22
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.

1 participant