Skip to content

fix(cli): apply task wait timeout to in-flight requests - #532

Merged
Sertaç Özercan (sozercan) merged 3 commits into
orka-agents:mainfrom
jabrailkhalil:fix/task-wait-deadline
Sep 12, 2026
Merged

Sertaç Özercan (sozercan) merged 3 commits into
orka-agents:mainfrom
jabrailkhalil:fix/task-wait-deadline

Conversation

@jabrailkhalil

@jabrailkhalil Jabrail (jabrailkhalil) commented Sep 9, 2026 •

Copy link
Copy Markdown
Contributor

A slow status response could let orka task wait --timeout report success after the wait expired. Polling and in-flight requests now share one context deadline. The polling loop checks cancellation before accepting a returned phase, and deadline expiry retains the timed out waiting for task <name> error.

Regression coverage includes cancellation during a request, timeout between polls, success before the deadline, failed phases, invalid durations, and a deterministic late-success case. The blocking HTTP test has independent handler shutdown and a two-second timeout allowance for command setup, so a cancellation regression fails without hanging cleanup.

Validation:

  • make lint-fix && make test
  • go test ./cmd/cli -run '^(TestTaskWait|TestWaitForTaskPhase)' -count=1 -timeout 30s
  • The HTTP regression passes with an injected 100 ms configuration-loading delay. Disabling timeout cancellation makes it fail within its own guard without hanging server cleanup; removing the post-fetch cancellation check fails the late-success regression.

Fixes #527.

Copilot AI balanced review requested due to automatic review settings September 9, 2026 19:07

Copilot AI left a comment

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

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

Copilot was unable to review this pull request because the user who requested the review has reached their quota limit.

@chatgpt-codex-connector

chatgpt-codex-connector Bot commented Sep 9, 2026 •

Copy link
Copy Markdown

Codex Review Summary

This comment shows the latest Codex review activity on this pull request.

Review Status Commit Review trigger
📝 Code Review ✅ Completed 2026-09-10T07:25:28.340385Z deb21d7 New commits
ℹ️ About Codex in GitHub

Your team has set up Codex to review pull requests in this repo. Reviews are triggered when you

Codex reacts with 👀 while any review is running, comments if it has suggestions, and reacts with 👍 once all reviews finish with no findings.

@chatgpt-codex-connector chatgpt-codex-connector Bot left a comment

Copy link
Copy Markdown

Choose a reason for hiding this comment

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

💡 Codex Review

Here are some automated review suggestions for this pull request.

Reviewed commit: 3d1a9a1890

ℹ️ About Codex in GitHub

Your team has set up Codex to review pull requests in this repo. Reviews are triggered when you

  • Open a pull request for review
  • Mark a draft as ready
  • Comment "Codex (@codex) review".

If Codex has suggestions, it will comment; otherwise it will react with 👍.

Codex can also answer questions or update the PR. Try commenting "Codex (@codex) address that feedback".

Comment thread cmd/cli/task.go Resolved
Derive the polling context from the configured timeout so an expired wait
cancels a pending status request instead of accepting a late success.
Previously the deadline was only consulted between polls, and a slow API
response could arrive after the deadline and still report success.

The signal-aware context remains the parent: interrupt/SIGTERM behaves as
before and still wins over the timeout. A deadline context is released
when the command returns. Both the request-error path and the polling
select map DeadlineExceeded to the same user-facing timed-out error.

Add httptest coverage: cancellation of a request that is in flight when
the deadline fires, timeout between polls, success before the deadline,
failed/cancelled phases, and invalid timeout strings.

Fixes orka-agents#527.

Signed-off-by: jabrailkhalil <jabrailkhalil@gmail.com>
Signed-off-by: jabrailkhalil <jabrailkhalil@gmail.com>
Copilot AI review requested due to automatic review settings September 9, 2026 19:45

Copilot AI left a comment

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

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

Copilot was unable to review this pull request because the user who requested the review has reached their quota limit.

Signed-off-by: Sertac Ozercan <sozercan@gmail.com>
Copilot AI review requested due to automatic review settings September 10, 2026 07:23