Skip to content

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

Merged
NianJiuZst merged 1 commit into
MiniMax-AI:mainfrom
ch-z-hc:fix/poll-deadline-sleep
Oct 16, 2026
Merged

NianJiuZst merged 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
Contributor

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
@NianJiuZst
NianJiuZst self-requested a review October 16, 2026 17:53
@NianJiuZst NianJiuZst self-assigned this Oct 16, 2026

@NianJiuZst NianJiuZst left a comment

Copy link
Copy Markdown
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Reviewed commit 78469b689b381ab890cf04a522f87d55e4540f43. No blocking findings; I recommend merging.

The change correctly caps the delay between polling attempts at the remaining deadline. It preserves the existing completed/failed response handling and does not change the timeout of an in-flight HTTP request.

I independently reproduced the regression: with a 50 ms polling timeout and a 1.5 s interval, unchanged main (8668aa5) took approximately 1,506 ms to reject, while this patch took approximately 52 ms. All 6 polling tests pass. Type checking and lint pass, with the existing unrelated warning in test/sdk/speech.test.ts.

The CI workflow for this exact head now passes, so the earlier CI hold is resolved.

@NianJiuZst NianJiuZst left a comment

Copy link
Copy Markdown
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Approve

@NianJiuZst
NianJiuZst merged commit 10b4ea0 into MiniMax-AI:main Oct 16, 2026
3 checks passed
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.

2 participants