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

  1. This is expected cancellation flow — no fix needed unless it occurs unexpectedly
  2. If unexpected, audit callers invoking cancel() (timeouts, connection close) and raise their limits
  3. 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

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


AI-assisted analysis of cube-js/cube@7d981676b3 (2026-09-02). Data as JSON: /api/errors/05d221344b76229f. Report an issue: GitHub.