Skip to content

fix(polling): honor context cancellation during waits - #727

Open
fallintoplace wants to merge 2 commits into
openai:mainfrom
fallintoplace:fix/polling-context-cancellation
Open

fix(polling): honor context cancellation during waits#727
fallintoplace wants to merge 2 commits into
openai:mainfrom
fallintoplace:fix/polling-context-cancellation

Conversation

@fallintoplace

@fallintoplace fallintoplace commented Jul 23, 2026

Copy link
Copy Markdown
Contributor

Summary

  • replace unconditional polling sleeps with context-aware waits
  • apply the behavior to vector store file, file batch, and video polling
  • cover cancellation through the public video polling helper

Why

The polling helpers checked context cancellation only after time.Sleep returned. Cancellation could therefore be delayed by the full caller-provided or server-provided polling interval.

The regression test cancels after a successful response has been consumed but before the poll wait starts, so it deterministically exercises the affected path.

Impact

Polling now returns promptly when its context is canceled, even during the wait between requests.

Checks

  • SKIP_MOCK_TESTS=true go test ./...
  • go test -race . -run TestVideoPollStatusReturnsWhenContextCancelled -count=10
  • ./scripts/lint
  • git diff --check

@fallintoplace
fallintoplace requested a review from a team as a code owner July 23, 2026 21:34
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