cube-js/cube · info

aborted

Error message

aborted

What it means

Inside cubeSqlStream(), an AbortError raised while consuming the JSONL stream is normalized to a plain Error with message 'aborted', matching the non-streaming cubeSql classification. It signals the caller cancelled the stream.

Source

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

              type: 'data' as const,
              data: parsed.data
            };
          } else if (parsed.error) {
            yield {
              type: 'error' as const,
              error: parsed.error
            };
          }
        } catch (parseError) {
          yield {
            type: 'error' as const,
            error: `Failed to parse remaining JSON: ${buffer}`
          };
        }
      }
    } catch (error: any) {
      if (error.name === 'AbortError') {
        throw new Error('aborted');
      }
      throw error;
    } finally {
      if (streamResponse.unsubscribe) {
        await streamResponse.unsubscribe();
      }
    }
  }
}

export default (apiToken: string | (() => Promise<string>), options: CubeApiOptions) => new CubeApi(apiToken, options);

export { CubeApi };
export { default as Meta } from './Meta.js';
export { default as SqlQuery } from './SqlQuery.js';
export { default as RequestError } from './RequestError.js';
export { default as ProgressResult } from './ProgressResult.js';
export { default as ResultSet } from './ResultSet.js';

View on GitHub (pinned to 7d981676b3)

Solutions

  1. Catch and treat 'aborted' as expected cancellation when using signals
  2. Abort only after fully consuming or intentionally stopping the stream
  3. Avoid aborting when you still need the remaining rows

Example fix

// before
const stream = client.cubeSqlStream(sql, { signal });
controller.abort(); // mid-consumption, unhandled
// after
try {
  for await (const chunk of client.cubeSqlStream(sql, { signal })) { /* ... */ }
} catch (e) {
  if (e.message === 'aborted') return; // expected cancellation
  throw e;
}
Defensive patterns

Strategy: try-catch

Try / catch

try {
  for await (const chunk of client.cubeSqlStream(sql, { signal })) { /* ... */ }
} catch (e) {
  if (e.message === 'aborted') return; // expected cancellation, not an error
  throw e;
}

Prevention

When it happens

Trigger: Aborting the AbortSignal passed as options.signal while cubeSqlStream is still yielding chunks (e.g. breaking early plus abort, or external abort).

Common situations: Cancelling live queries in UIs; component unmount cleanup; combining early generator return with controller.abort().

Related errors


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