Honor request cancellation during jq evaluation - #108
Merged
Conversation
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>
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
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 byClient.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" --> JQThe earlier signal wins. Responses constructed directly without an
http.Requestcontinue 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
EvaluationJQwitherrors.Is(err, context.Canceled)support.🤖 Generated with Claude Code