Skip to content

fix: bound polling requests by the remaining timeout - #300

Open
Ricardo-M-L wants to merge 1 commit into
MiniMax-AI:mainfrom
Ricardo-M-L:fix/poll-request-deadline-20261022
Open

Ricardo-M-L wants to merge 1 commit into
MiniMax-AI:mainfrom
Ricardo-M-L:fix/poll-request-deadline-20261022

Conversation

@Ricardo-M-L

@Ricardo-M-L Ricardo-M-L commented Oct 22, 2026 •

Copy link
Copy Markdown

Summary

Bound each polling HTTP request by the polling time remaining, while preserving a shorter configured request timeout.

The loop already bounds the sleep between requests, but an in-flight status request can outlive the entire remaining polling budget. For example, a 50 ms polling budget with a 1 s request timeout currently waits around 1 s when the server stalls. This is separate from the sleep fix in #283.

Changes

  • Recompute the remaining budget before every polling request and pass the smaller of that budget and config.timeout.
  • Convert fractional-second request budgets into integer milliseconds suitable for Node's AbortSignal.timeout, correcting floating-point noise around whole milliseconds and rounding genuine fractional milliseconds down.
  • Preserve TimeoutError and AbortError while reading both successful and HTTP-error response bodies. Malformed JSON retains the existing error mapping.
  • Add regression coverage for pending requests, subsequent polling iterations, shorter request timeouts, millisecond boundaries, and both body-reading paths.

This bounds the HTTP wait at the start of each polling iteration. It does not redesign OAuth credential refresh or claim a strict wall-clock deadline during credential resolution or event-loop blocking.

Validation

Base: 38aba5f26173dd1065b115b221d79c9ddd87c6bb.

  • The initial pending-request and subsequent-budget regressions fail against the unmodified implementation.
  • Targeted polling, HTTP, CLI video, and SDK video tests: 67 passed.
  • Full suite: 636 passed, 1 failed; pristine base in the same environment: 613 passed, the same 1 failed. The unchanged failure is the macOS Zed XDG_CONFIG_HOME expectation in editor configuration tests. Browser launcher commands were stubbed in both runs to avoid opening a browser; tests were not skipped.
  • bun run typecheck, bun run lint, and bun run build pass (lint retains one existing speech any warning).
  • Built CLI Node smoke checks pass.
  • Real Node HTTP server probes cover stalled headers, a partial 200 JSON body, and a partial 500 JSON body: the 50 ms budget aborts in roughly 52–55 ms. The original header/body cases take roughly 1 s. Body timeouts retain timeout exit code 5 rather than becoming a general JSON error.
  • Two independent review rounds were performed as required by AGENTS.md; confirmed first-round findings were fixed, and both second-round reviewers reported no blocking findings. Both independently ran the 37 HTTP/polling tests and native Node timeout checks.
  • git diff --check passes.
bun test test/polling/poll.test.ts test/client/http.test.ts test/commands/video/generate.test.ts test/sdk/video.test.ts
bun run typecheck
bun run lint
bun run build

Implemented and tested with OpenAI Codex assistance. Independent reviews above were agent reviews, not a claim of maintainer or human approval.


View with [code]smith Autofix with [code]smith
Need help on this PR? Tag @codesmith-bot with what you need.

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