cube-js/cube · error

CubeSQL query was aborted

Error message

CubeSQL query was aborted

What it means

If the transport reports the request was aborted (response.error === 'aborted'), cubeSql() throws 'CubeSQL query was aborted'. This means the request was cancelled before completing, typically via an AbortSignal.

Source

Thrown at packages/cubejs-client-core/src/index.ts:817

        const request = this.request('cubesql', cubesqlParams);

        return request;
      },
      (response: any) => {
        // TODO: The response is sending both errors and successful results as `error`
        if (!response || !response.error) {
          throw new Error('Invalid response format');
        }

        // Check if this is a timeout or abort error from transport
        if (response.error === 'timeout') {
          const timeoutMs = options?.timeout || 5 * 60 * 1000;
          throw new Error(`CubeSQL query timed out after ${timeoutMs}ms`);
        }

        if (response.error === 'aborted') {
          throw new Error('CubeSQL query was aborted');
        }

        const [schema, ...data] = response.error.split('\n');

        let parsedSchema: any;
        try {
          parsedSchema = JSON.parse(schema);
        } catch (err) {
          // Schema line isn't valid JSON — the whole `error` payload is a real error.
          throw new Error(response.error);
        }

        const rows: any[] = [];

        for (const line of data) {
          if (line.trim().length) {
            let parsed: any;
            try {

View on GitHub (pinned to 7d981676b3)

Solutions

  1. Only abort when cancellation is actually intended; keep the AbortController alive for the request duration
  2. Wrap the call in try/catch and treat 'CubeSQL query was aborted' as an expected cancellation, not a failure
  3. Re-issue the query if the abort was accidental

Example fix

// before
controller.abort(); // accidentally called on every render
// after
useEffect(() => () => controller.abort(), []); // abort only on unmount
Defensive patterns

Strategy: try-catch

Validate before calling

const controller = new AbortController();
// do not call controller.abort() before the query completes unless cancelling is intended

Try / catch

try {
  const res = await client.cubeSql(sql, { signal: controller.signal });
} catch (e) {
  if (e.message === 'CubeSQL query was aborted') return null; // expected cancellation
  throw e;
}

Prevention

When it happens

Trigger: Passing options.signal and aborting the controller while a cubeSql call is in flight; underlying fetch aborted by the transport.

Common situations: React cleanup aborting requests on unmount; user cancelling a long query; timeout infrastructure triggering AbortController.

Related errors


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