{"record":{"id":"84bea810b662e1a8","repo":"cube-js/cube","slug":"cubesql-query-timed-out-after-timeoutms-ms","errorCode":null,"errorMessage":"CubeSQL query timed out after ${timeoutMs}ms","messagePattern":"CubeSQL query timed out after (.+?)ms","errorType":"exception","errorClass":null,"httpStatus":null,"severity":"error","filePath":"packages/cubejs-client-core/src/index.ts","lineNumber":813,"sourceCode":"\n        if (options?.timezone) {\n          cubesqlParams.timezone = options.timezone;\n        }\n\n        const request = this.request('cubesql', cubesqlParams);\n\n        return request;\n      },\n      (response: any) => {\n        // TODO: The response is sending both errors and successful results as `error`\n        if (!response || !response.error) {\n          throw new Error('Invalid response format');\n        }\n\n        // Check if this is a timeout or abort error from transport\n        if (response.error === 'timeout') {\n          const timeoutMs = options?.timeout || 5 * 60 * 1000;\n          throw new Error(`CubeSQL query timed out after ${timeoutMs}ms`);\n        }\n\n        if (response.error === 'aborted') {\n          throw new Error('CubeSQL query was aborted');\n        }\n\n        const [schema, ...data] = response.error.split('\\n');\n\n        let parsedSchema: any;\n        try {\n          parsedSchema = JSON.parse(schema);\n        } catch (err) {\n          // Schema line isn't valid JSON — the whole `error` payload is a real error.\n          throw new Error(response.error);\n        }\n\n        const rows: any[] = [];\n","sourceCodeStart":795,"sourceCodeEnd":831,"githubUrl":"https://github.com/cube-js/cube/blob/7d981676b36392fec34088b9afab6bdcad40207c/packages/cubejs-client-core/src/index.ts#L795-L831","documentation":"When the transport reports the CubeSQL request failed with error 'timeout', cubeSql() rethrows a descriptive timeout error including the effective timeout in milliseconds. The default timeout is 5 minutes unless options.timeout overrides it.","triggerScenarios":"cubeSql(sql, { timeout }) where the server/transport exceeds the deadline; no options.timeout means the 5-minute (300000ms) default elapses on a long-running SQL query.","commonSituations":"Very large CubeSQL queries over slow connections; server-side query taking minutes; too-low custom timeout set by the caller.","solutions":["Increase the timeout: cubeSql(sql, { timeout: 600000 })","Optimize the query / use pre-aggregations so it finishes faster","Check server health/load if queries that used to be fast now time out"],"exampleFix":"// before\nconst res = await client.cubeSql('SELECT * FROM huge_table');\n// after\nconst res = await client.cubeSql('SELECT * FROM huge_table', { timeout: 10 * 60 * 1000 });","handlingStrategy":"retry","validationCode":"const effectiveTimeoutMs = options?.timeout ?? 5 * 60 * 1000;\nif (expectedQueryMs > effectiveTimeoutMs) console.warn('Query likely to exceed cubeSql timeout');","typeGuard":null,"tryCatchPattern":"try { const res = await client.cubeSql(sql, { timeout: 600000 }); } catch (e) {\n  if (/timed out after \\d+ms/.test(e.message)) {\n    const res = await withBackoff(() => client.cubeSql(sql, { timeout: 600000 }));\n  } else throw e;\n}","preventionTips":["Set an explicit timeout matching expected query duration","Optimize heavy queries / pre-aggregations","Alert on server-side query latency"],"tags":["cubesql","timeout","network"],"backgroundTag":"request-timeout","analyzedSha":"7d981676b36392fec34088b9afab6bdcad40207c","analyzedAt":"2026-09-02T03:45:10.400Z","contentChangedAt":null,"schemaVersion":2},"datasetVersion":"2026-09-08T15:18:49.778Z"}