Skip to content

Honor request cancellation during jq evaluation - #108

Merged
korya merged 1 commit into
masterfrom
korya-fix-jq-request-cancellation
Aug 31, 2026
Merged

Honor request cancellation during jq evaluation#108
korya merged 1 commit into
masterfrom
korya-fix-jq-request-cancellation

Conversation

@korya

@korya korya commented Aug 31, 2026

Copy link
Copy Markdown
Owner

Problem

Cancelling an HTTP assertion request does not stop an in-progress jq expression, delaying shutdown by up to the separate ten-second jq timeout.

The evaluator starts from context.Background, disconnecting it from the request lifecycle used by Client.Do. A runaway but valid jq program therefore keeps consuming CPU after its caller has cancelled or reached an earlier deadline.

Solution

Derive jq evaluation from the response request context while retaining the package timeout as an independent safety ceiling.

flowchart LR
    Request["response request context"] -- "cancel or earlier deadline" --> JQ["jq evaluation"]
    Guard["10-second package ceiling"] -- "fallback deadline" --> JQ
Loading

The earlier signal wins. Responses constructed directly without an http.Request continue to use a background context plus the existing ten-second ceiling, preserving standalone assertion use and the runaway-query guarantee.

No visual change: this changes cancellation behavior without changing successful results or CLI rendering.

Other Changes

  • Add a regression test using a valid recursive jq program and a cancelled request context.
  • Preserve error classification as EvaluationJQ with errors.Is(err, context.Canceled) support.

🤖 Generated with Claude Code

A cancelled request could still spend up to ten seconds evaluating a runaway jq expression because
its assertion started from context.Background. Derive evaluation from the response request context
while retaining the package timeout as a backstop for responses without a deadline.

Co-Authored-By: OpenAI Codex (GPT-5) <noreply@openai.com>
@korya
korya marked this pull request as ready for review August 31, 2026 01:00
@korya
korya merged commit fd40de4 into master Aug 31, 2026
8 checks passed
@korya
korya deleted the korya-fix-jq-request-cancellation branch August 31, 2026 01:01
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