cube-js/cube · info
Query was cancelled
Error message
Query was cancelled
What it means
AthenaDriver.downloadQueryResults runs the query inside a cancelable async promise. If `cancel()` is invoked (setting `cancelled = true`) after `startQuery` resolves but before execution finishes, the promise stops the query and throws 'Query was cancelled'. The first check happens immediately after startQuery.
Source
Thrown at packages/cubejs-athena-driver/src/AthenaDriver.ts:277
}
/**
* Executes query and returns table memory data that includes rows
* and queried fields types.
* Returns a cancelable promise that will stop the Athena query on cancel.
*/
public memory(
query: string,
values: unknown[],
): MaybeCancelablePromise<DownloadTableMemoryData & { types: TableStructure }> {
let qid: AthenaQueryId | null = null;
let cancelled = false;
const promise: any = (async () => {
qid = await this.startQuery(query, values);
if (cancelled) {
await this.stopQuery(qid);
throw new Error('Query was cancelled');
}
await this.waitForSuccess(qid, () => cancelled);
const iter = this.lazyRowIterator(qid, query, true);
const types = <TableStructure><unknown>((await iter.next()).value);
const rows: Row[] = [];
for await (const row of iter) {
if (cancelled) throw new Error('Query was cancelled');
rows.push(<Row>row);
}
return { types, rows };
})();
promise.cancel = async () => {
cancelled = true;
if (qid) {
await this.stopQuery(qid);
}
};View on GitHub (pinned to 7d981676b3)
Solutions
- This is expected cancellation flow — no fix needed unless it occurs unexpectedly
- If unexpected, audit callers invoking cancel() (timeouts, connection close) and raise their limits
- Handle the error gracefully in consuming code by checking the message before surfacing to users
Example fix
// before
const rows = await driver.downloadQueryResults(query, values)
// after
try {
const rows = await driver.downloadQueryResults(query, values)
} catch (e) {
if (e.message !== 'Query was cancelled') throw e
// treat as abort, not failure
} Defensive patterns
Strategy: try-catch
Validate before calling
if (isCancelledBeforeStart) { // skip calling the driver at all
throw new AbortError()
} Try / catch
try {
const result = await driver.downloadQueryResults(query, values)
} catch (e) {
if (e && e.message === 'Query was cancelled') return /* treat as abort */
throw e
} Prevention
- Set realistic orchestrator timeouts so queries are not cancelled mid-flight
- Keep a reference to cancelable promises and only cancel intentionally
- Treat cancellation errors as a distinct control-flow code path in your data layer
When it happens
Trigger: Caller calls promise.cancel() on the promise returned by downloadQueryResults while startQuery is still pending, so the post-start cancellation check fires.
Common situations: User aborts a download in the UI, request timeouts in the orchestrator cancelling in-flight queries, or Cube shutting down and cancelling queued driver work.
Related errors
- ${queryExecution.QueryExecution?.Status?.StateChangeReason}
- Query has been cancelled
- Athena job timeout reached ${this.config.pollTimeout}ms
- Unload is not configured. Please define CUBEJS_AWS_S3_OUTPUT
- Export bucket is not configured.
AI-assisted analysis of cube-js/cube@7d981676b3 (2026-09-02).
Data as JSON: /api/errors/05d221344b76229f.
Report an issue: GitHub.