Skip to content

Enforce --timeout when waiting for unshaped execution results - #69

Merged
ivpusic merged 2 commits into
mainfrom
fix-results-timeout
Nov 20, 2026
Merged

ivpusic merged 2 commits into
mainfrom
fix-results-timeout

Conversation

@ivpusic

@ivpusic ivpusic commented Nov 20, 2026 •

Copy link
Copy Markdown
Member

dune execution results ignored --timeout without --columns/--filter/--sort-by/--sample: a query that kept running was waited on forever. Both paths now poll the execution status until the deadline and download the rows once. Follow-up from Norbert's review of #67.

Impact

  • execution results without shaping flags, when waiting (the default). --no-wait is unchanged.
  • The unshaped path used the SDK's WaitGetResults, whose maxRetries counts only errors. It also downloaded every row while polling and again for the final fetch. It now uses waitForExecution, the status poll the shaped path already used.
  • At the deadline, a still-running execution now fails with execution <id> is still EXECUTING after <n>s; ... on both paths. Fix CLI issues found testing the MCP parity commands live #68 added this for the shaped path, and this PR is rebased onto it.
  • waitForExecution retries transient failures (network errors, 5xx, 429) until the deadline, printing a note to stderr for each retry, and then returns retries have been exhausted: <error>. Any other 4xx, such as an unknown execution ID or a bad API key, fails on the first call.

Context for reviewers

  • TestResultsWaitStopsAtTheTimeout hangs on main (killed at 8s) and passes here in about 1s.

  • The wait tests now mock QueryStatus. They assert one row download per command, error recovery, and retries until the timeout.

  • Not changed: query run and query run-sql wait the same way (cmd/query/helpers.go calls WaitGetResults), so their --timeout likely has the same gap.

  • No visual surface: CLI change with no rendered UI; verified with unit tests (go vet ./..., go test -race ./...).

@norbertdurcansk norbertdurcansk 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.

Approved, with suggestions. The fix is right: both paths now wait on the status, rows download once, and --timeout is honoured. Tests pass locally (go test -race ./cmd/execution/...).

Two suggestions inline, both about errors that will never succeed now being retried silently until the timeout.

Out of scope: as the description notes, query run / query run-sql still use WaitGetResults in cmd/query/helpers.go, so their --timeout likely has the same gap. Worth a follow-up.

Comment thread cmd/execution/results.go Resolved
Comment thread cmd/execution/results_test.go Resolved
ivpusic and others added 2 commits November 20, 2026 10:05
The unshaped path waited with the SDK's WaitGetResults, whose maxRetries
counts only errors, so a query that kept running was waited on forever,
and every row was downloaded once while waiting and again at the end.
Both paths now poll the execution status until the deadline, retrying
failed status calls until then, and download the rows once.

Amp-Thread-ID: https://ampcode.com/threads/T-01a1f46d-4de8-7404-a66a-7e2a8be6632a
Co-authored-by: Amp <amp@ampcode.com>
A 4xx status response other than 429, such as an unknown execution ID or
a bad API key, cannot succeed on retry, so it is returned right away.
Other failures are still retried until --timeout, each with a note on
stderr so a long wait is not silent.

Amp-Thread-ID: https://ampcode.com/threads/T-01a1f46d-4de8-7404-a66a-7e2a8be6632a
Co-authored-by: Amp <amp@ampcode.com>
@ivpusic
ivpusic force-pushed the fix-results-timeout branch from 6502bf8 to 30d210e Compare November 20, 2026 10:05
@ivpusic
ivpusic merged commit 6c6a20a into main Nov 20, 2026
6 checks passed
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.

2 participants