{"record":{"id":"fc7c07a677b26446","repo":"cube-js/cube","slug":"cubesql-query-was-aborted","errorCode":null,"errorMessage":"CubeSQL query was aborted","messagePattern":"CubeSQL query was aborted","errorType":"exception","errorClass":null,"httpStatus":null,"severity":"error","filePath":"packages/cubejs-client-core/src/index.ts","lineNumber":817,"sourceCode":"\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\n        for (const line of data) {\n          if (line.trim().length) {\n            let parsed: any;\n            try {","sourceCodeStart":799,"sourceCodeEnd":835,"githubUrl":"https://github.com/cube-js/cube/blob/7d981676b36392fec34088b9afab6bdcad40207c/packages/cubejs-client-core/src/index.ts#L799-L835","documentation":"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.","triggerScenarios":"Passing options.signal and aborting the controller while a cubeSql call is in flight; underlying fetch aborted by the transport.","commonSituations":"React cleanup aborting requests on unmount; user cancelling a long query; timeout infrastructure triggering AbortController.","solutions":["Only abort when cancellation is actually intended; keep the AbortController alive for the request duration","Wrap the call in try/catch and treat 'CubeSQL query was aborted' as an expected cancellation, not a failure","Re-issue the query if the abort was accidental"],"exampleFix":"// before\ncontroller.abort(); // accidentally called on every render\n// after\nuseEffect(() => () => controller.abort(), []); // abort only on unmount","handlingStrategy":"try-catch","validationCode":"const controller = new AbortController();\n// do not call controller.abort() before the query completes unless cancelling is intended","typeGuard":null,"tryCatchPattern":"try {\n  const res = await client.cubeSql(sql, { signal: controller.signal });\n} catch (e) {\n  if (e.message === 'CubeSQL query was aborted') return null; // expected cancellation\n  throw e;\n}","preventionTips":["Tie AbortController lifecycle to component unmount only","Never share one controller across unrelated requests","Document cancellation semantics in calling code"],"tags":["cubesql","abort","cancellation"],"backgroundTag":"request-aborted","analyzedSha":"7d981676b36392fec34088b9afab6bdcad40207c","analyzedAt":"2026-09-02T03:45:10.400Z","contentChangedAt":null,"schemaVersion":2},"datasetVersion":"2026-09-08T15:18:49.778Z"}