{"record":{"id":"50cec15aa591ac8d","repo":"cube-js/cube","slug":"query-cancelled","errorCode":null,"errorMessage":"Query cancelled","messagePattern":"Query cancelled","errorType":"exception","errorClass":null,"httpStatus":null,"severity":"info","filePath":"packages/cubejs-druid-driver/src/DruidClient.ts","lineNumber":69,"sourceCode":"      };\n\n      try {\n        const response = await this.getClient().request({\n          url: '/druid/v2/sql/',\n          method: 'POST',\n          data: {\n            query,\n            parameters,\n            header: true,\n            sqlTypesHeader: true,\n            resultFormat: 'object',\n          },\n        });\n\n        if (cancelled && response.headers['x-druid-sql-query-id']) {\n          await this.cancel(response.headers['x-druid-sql-query-id']);\n\n          throw new Error('Query cancelled');\n        }\n\n        if (response.headers['x-druid-sql-header-included']) {\n          const [columns, ...rows] = response.data;\n\n          return {\n            columns,\n            rows\n          };\n        } else {\n          return {\n            columns: null,\n            rows: response.data,\n          };\n        }\n      } catch (e: any) {\n        if (cancelled) {\n          throw new Error('Query cancelled');","sourceCodeStart":51,"sourceCodeEnd":87,"githubUrl":"https://github.com/cube-js/cube/blob/7d981676b36392fec34088b9afab6bdcad40207c/packages/cubejs-druid-driver/src/DruidClient.ts#L51-L87","documentation":"DruidClient.query() tracks whether the caller cancelled the query. If cancellation is detected and the successful HTTP response still carries an x-druid-sql-query-id header, the client cancels the running Druid SQL query server-side and then throws 'Query cancelled' instead of returning the (unwanted) results.","triggerScenarios":"Calling driver.query()/client.query() and cancelling the request (e.g. via an abort signal or cancel callback) while the HTTP response arrives with an x-druid-sql-query-id header, so the client aborts the query and throws instead of returning rows.","commonSituations":"Users navigating away in a dashboard causing Cube to cancel in-flight queries; query queue timeouts cancelling Druid queries; long-running Druid SQL calls cancelled by the orchestrator.","solutions":["Nothing is wrong per se — handle/rethrow cancellation in your error handling and filter it from retry logic.","Increase the query timeout or orchestrator concurrency limits if cancellations are unwanted.","Check for abandoned dashboard queries causing mass cancellation; reduce pre-aggregation/query churn."],"exampleFix":"// before\ncatch (e) { console.error(e); }\n// after\ncatch (e) {\n  if (e.message === 'Query cancelled') return; // expected on abort\n  console.error(e);\n}","handlingStrategy":"try-catch","validationCode":null,"typeGuard":"function isQueryCancelled(e) {\n  return e instanceof Error && e.message === 'Query cancelled';\n}","tryCatchPattern":"try {\n  await druidDriver.query(query, values);\n} catch (e) {\n  if (e.message === 'Query cancelled') return null; // expected on abort\n  throw e;\n}","preventionTips":["Avoid cancelling queries unnecessarily; tune queryTimeout and queue settings","Filter cancellation errors from retry/alerting pipelines","Monitor cancellation frequency to detect dashboard churn"],"tags":["cancellation","druid","query-lifecycle","async"],"backgroundTag":"query-cancelled","analyzedSha":"7d981676b36392fec34088b9afab6bdcad40207c","analyzedAt":"2026-09-02T03:45:10.400Z","contentChangedAt":null,"schemaVersion":2},"datasetVersion":"2026-09-08T15:18:49.778Z"}