{"record":{"id":"a26a0f4dea0762ee","repo":"cube-js/cube","slug":"cube-store-request-size-of-formatsize-buffer-len","errorCode":null,"errorMessage":"Cube Store request size of ${formatSize(buffer.length)} exceeds the maximum message size of ${formatSize(this.maxMessageSize)}. Reduce the size of the query and of the inline tables it sends, or raise CUBEJS_CUBESTORE_MAX_MESSAGE_SIZE together with CUBESTORE_TRANSPORT_MAX_MESSAGE_SIZE on the Cube Store side.","messagePattern":"Cube Store request size of (.+?) exceeds the maximum message size of (.+?)\\. Reduce the size of the query and of the inline tables it sends, or raise CUBEJS_CUBESTORE_MAX_MESSAGE_SIZE together with CUBESTORE_TRANSPORT_MAX_MESSAGE_SIZE on the Cube Store side\\.","errorType":"exception","errorClass":"MessageTooLargeError","httpStatus":null,"severity":"error","filePath":"packages/cubejs-cubestore-driver/src/WebSocketConnection.ts","lineNumber":425,"sourceCode":"      webSocket.fatalError = null;\n      this.webSocket = webSocket;\n    }\n\n    return this.webSocket!.readyPromise;\n  }\n\n  private retryWaitTime() {\n    return 1000 * (this.currentConnectionTry + 1);\n  }\n\n  private async sendMessage(messageId: number, buffer: Uint8Array): Promise<any> {\n    if (buffer.length > this.maxMessageSize) {\n      // Cube Store would close the connection on such a message, which shows up\n      // as an unrelated `write EPIPE`, so report it before sending anything.\n      // This only catches what is over our own limit: Cube Store applies its\n      // own, by default stricter, CUBESTORE_TRANSPORT_MAX_MESSAGE_SIZE, and a\n      // message it refuses is reported once it closes the connection.\n      throw new MessageTooLargeError(\n        `Cube Store request size of ${formatSize(buffer.length)} exceeds the maximum message size of ` +\n        `${formatSize(this.maxMessageSize)}. Reduce the size of the query and of the inline tables it sends, ` +\n        'or raise CUBEJS_CUBESTORE_MAX_MESSAGE_SIZE together with CUBESTORE_TRANSPORT_MAX_MESSAGE_SIZE ' +\n        'on the Cube Store side.'\n      );\n    }\n\n    const socket = await this.initWebSocket();\n    return new Promise((resolve, reject) => {\n      socket.sentMessages[messageId] = { resolve, reject, buffer, fatalRounds: 0 };\n\n      // If socket is closing this message should be resent\n      if (socket.readyState === WebSocket.OPEN) {\n        socket.send(buffer, (err) => {\n          if (err) {\n            // Leave the message registered and let 'close' re-send it over a\n            // new connection instead of failing it with the write error.\n            socket.terminate();","sourceCodeStart":407,"sourceCodeEnd":443,"githubUrl":"https://github.com/cube-js/cube/blob/7d981676b36392fec34088b9afab6bdcad40207c/packages/cubejs-cubestore-driver/src/WebSocketConnection.ts#L407-L443","documentation":"The driver enforces a client-side maximum WebSocket message size (CUBEJS_CUBESTORE_MAX_MESSAGE_SIZE). Sending a larger frame would make Cube Store close the connection with an unrelated EPIPE error, so the driver checks first and throws MessageTooLargeError with actionable guidance. Large inline tables in queries are the usual cause.","triggerScenarios":"query() serializing a request whose flatbuffer exceeds maxMessageSize — commonly loading large data chunks or sending big inline (limited) tables to Cube Store.","commonSituations":"High-volume pre-aggregation loads; uploading large arrays as inline tables; default max message size too small for the workload.","solutions":["Reduce the query size / batch inline tables into smaller chunks","Raise CUBEJS_CUBESTORE_MAX_MESSAGE_SIZE on the Cube side AND CUBESTORE_TRANSPORT_MAX_MESSAGE_SIZE on Cube Store side","Stream/load data via external sources instead of inline tables","Break large loads into multiple smaller uploads"],"exampleFix":"// before\ndriver.query(loadQuery, params, { inlineTables: hugeTables });\n// after\ntableBatches.chunk(hugeTables, 8_000_000).forEach(batch =>\n  driver.query(loadQuery, params, { inlineTables: batch }));\n// or set env\n// CUBEJS_CUBESTORE_MAX_MESSAGE_SIZE=104857600, CUBESTORE_TRANSPORT_MAX_MESSAGE_SIZE=104857600","handlingStrategy":"validation","validationCode":"const MAX = 16 * 1024 * 1024; // match CUBEJS_CUBESTORE_MAX_MESSAGE_SIZE\nif (inlineTables) {\n  const size = JSON.stringify(inlineTables).length;\n  if (size > MAX) throw new Error(`inline tables too large: ${size} > ${MAX}`);\n}","typeGuard":"const fitsMessageSize = (buf, max) => buf.length <= max;","tryCatchPattern":"try {\n  await driver.query(sql, params, { inlineTables });\n} catch (e) {\n  if (e.name === 'MessageTooLargeError' || /exceeds the maximum message size/.test(e.message)) {\n    return sendInBatches(sql, params, inlineTables);\n  }\n  throw e;\n}","preventionTips":["Chunk large inline tables before sending (batch loads)","Set CUBEJS_CUBESTORE_MAX_MESSAGE_SIZE and CUBESTORE_TRANSPORT_MAX_MESSAGE_SIZE consistently on both sides","Prefer external loading (e.g. loading via queries) over giant inline payloads","Estimate payload size in app code before calling query()"],"tags":["cubestore","websocket","message-size","configuration"],"backgroundTag":"message-size-exceeded","analyzedSha":"7d981676b36392fec34088b9afab6bdcad40207c","analyzedAt":"2026-09-02T03:45:10.400Z","contentChangedAt":null,"schemaVersion":2},"datasetVersion":"2026-09-08T15:18:49.778Z"}