cube-js/cube · error
Stream query failed: ${e}; query id: ${queryId}
Error message
Stream query failed: ${e}; query id: ${queryId} What it means
Generic wrapper for any exception thrown while setting up or consuming the streaming query in stream(). The original error `e` is string-interpolated into the message (there is no `cause` preserved), along with the ClickHouse query id, so the root cause must be recovered from the interpolated text.
Source
Thrown at packages/cubejs-clickhouse-driver/src/ClickHouseDriver.ts:451
const rowStream = Readable.from(dataRowsIter);
return {
rowStream,
types: names.map((name, idx) => {
const type = types[idx];
return {
name,
type: this.toGenericType(type),
};
}),
release: async () => {
await client.close();
}
};
} catch (e) {
await client.close();
// TODO replace string formatting with proper cause
throw new Error(`Stream query failed: ${e}; query id: ${queryId}`);
}
}
public async downloadQueryResults(
query: string,
values: unknown[],
options: DownloadQueryResultsOptions
): Promise<DownloadQueryResultsResult> {
if ((options ?? {}).streamImport) {
return this.stream(query, values, options);
}
const response = await this.queryResponse(query, values);
return {
rows: this.normaliseResponse(response),
types: (response.meta ?? []).map((field) => ({
name: field.name,View on GitHub (pinned to 7d981676b3)
Solutions
- Parse the interpolated `${e}` text for the root cause (connection refused, auth failed, syntax error, etc.) and fix that underlying issue first
- Use the query id in the message to look up the query in ClickHouse system.query_log for the server-side error
- Verify CLICKHOUSECubeJS config: url, port, user, password, database are correct and reachable
- Increase query/execution timeouts for large streaming result sets
- Upgrade the driver — newer versions replace string formatting with proper error causes
Example fix
// before
throw new Error(`Stream query failed: ${e}; query id: ${queryId}`);
// after (in driver)
throw new Error(`Stream query failed: ${e}; query id: ${queryId}`, { cause: e }); Defensive patterns
Strategy: try-catch
Validate before calling
// Verify connectivity/credentials up front
await driver.query('SELECT 1', []); Type guard
null
Try / catch
try { return await driver.downloadQueryResults(q, v); }
catch (e) {
const m = String(e.message);
const queryId = m.match(/query id: ([^\s]+)/)?.[1];
log.error('stream query failed', { queryId, cause: m });
throw e;
} Prevention
- Extract and log the query id for ClickHouse system.query_log lookups
- Validate ClickHouse credentials and connectivity at startup
- Set realistic timeouts for large streaming queries
When it happens
Trigger: Any failure inside the try block of stream() called via downloadQueryResults(): client creation or query execution failures, connection/auth errors, or errors thrown by the row iteration (including errors 160/161 which get re-wrapped by this handler).
Common situations: Wrong ClickHouse credentials/host/port; network unreachable; query syntax errors; context timeouts on large streaming queries; underlying stream-end errors wrapped by this message.
Related errors
- Unexpected stream end before row with types
- Connection check failed: ${errorMessage}
- Query failed: ${e}; query id: ${queryId}
- Unexpected stream end before row with names
- Unexpected names and types length mismatch; names ${names.le
AI-assisted analysis of cube-js/cube@7d981676b3 (2026-09-02).
Data as JSON: /api/errors/c6a71ad5411e25da.
Report an issue: GitHub.