{"record":{"id":"23d70ea3af7a9301","repo":"cube-js/cube","slug":"cube-store-response-size-exceeds-the-maximum-messa","errorCode":null,"errorMessage":"Cube Store response size exceeds the maximum message size of ${formatSize(this.maxMessageSize)}. Reduce the amount of data the query returns, e.g. by adding filters or a limit, or raise CUBEJS_CUBESTORE_MAX_MESSAGE_SIZE.","messagePattern":"Cube Store response size exceeds the maximum message size of (.+?)\\. Reduce the amount of data the query returns, e\\.g\\. by adding filters or a limit, or raise CUBEJS_CUBESTORE_MAX_MESSAGE_SIZE\\.","errorType":"exception","errorClass":"MessageTooLargeError","httpStatus":null,"severity":"error","filePath":"packages/cubejs-cubestore-driver/src/WebSocketConnection.ts","lineNumber":195,"sourceCode":"              // failing it here would surface a spurious `write EPIPE` for a\n              // query that never reached Cube Store.\n              webSocket.terminate();\n            }\n\n            resolveSend();\n          });\n        });\n        webSocket.on('open', () => resolve(webSocket));\n        webSocket.on('error', (err) => {\n          if ((err as any).code === MAX_PAYLOAD_EXCEEDED_CODE) {\n            // Cube Store answered with a message bigger than this connection\n            // accepts, and `ws` is tearing the connection down. Neither\n            // reconnecting nor retrying the query helps: the response would be\n            // just as big. Pending messages are rejected by the 'close' handler.\n            webSocket.fatalError = new MessageTooLargeError(\n              `Cube Store response size exceeds the maximum message size of ${formatSize(this.maxMessageSize)}. ` +\n              'Reduce the amount of data the query returns, e.g. by adding filters or a limit, ' +\n              'or raise CUBEJS_CUBESTORE_MAX_MESSAGE_SIZE.',\n              err\n            );\n\n            if (webSocket === this.webSocket) {\n              this.webSocket = null;\n            }\n\n            // No-op if the connection was already established.\n            reject(webSocket.fatalError);\n\n            return;\n          }\n\n          // The socket is done either way, so stop its heartbeat now rather than\n          // relying on a 'close' that may not follow: the interval is what keeps\n          // the socket, and everything reachable from it, alive.\n          webSocket.teardown();\n","sourceCodeStart":177,"sourceCodeEnd":213,"githubUrl":"https://github.com/cube-js/cube/blob/7d981676b36392fec34088b9afab6bdcad40207c/packages/cubejs-cubestore-driver/src/WebSocketConnection.ts#L177-L213","documentation":"The Cube Store WebSocket driver rejects responses whose serialized size exceeds the client limit CUBEJS_CUBESTORE_MAX_MESSAGE_SIZE. Instead of failing the reconnect loop, it sets a fatalError (MessageTooLargeError) on the socket because retrying would return the same oversized response.","triggerScenarios":"A query returns a result frame larger than maxMessageSize when read off the WebSocket from Cube Store — typically huge result sets or large pre-aggregation downloads.","commonSituations":"Unaggregated queries returning millions of rows, pulling large arrays/measures without limit, small CUBEJS_CUBESTORE_MAX_MESSAGE_SIZE relative to dataset.","solutions":["Reduce returned data: add filters, time dimensions, or a row limit to the query.","Aggregate in Cube (pre-aggregations, rollups) instead of returning raw rows.","Raise CUBEJS_CUBESTORE_MAX_MESSAGE_SIZE (and the matching Cube Store side limits) if the payload is genuinely needed."],"exampleFix":"// before\nconst rs = await cube.query({ measures: ['Orders.count'], dimensions: ['Orders.id'] });\n// after\nconst rs = await cube.query({ measures: ['Orders.count'], dimensions: ['Orders.status'], limit: 10000 });","handlingStrategy":"try-catch","validationCode":null,"typeGuard":null,"tryCatchPattern":"try {\n  const rs = await connection.query(query);\n} catch (e) {\n  if (e instanceof MessageTooLargeError) {\n    // shrink query (filters/limit) or raise CUBEJS_CUBESTORE_MAX_MESSAGE_SIZE\n  }\n  throw e;\n}","preventionTips":["Set CUBEJS_CUBESTORE_MAX_MESSAGE_SIZE appropriately for your result sizes","Always apply limits/filters to exploratory queries","Prefer aggregations over raw row dumps"],"tags":["cubestore","websocket","message-size","config"],"backgroundTag":"message-size-exceeded","analyzedSha":"7d981676b36392fec34088b9afab6bdcad40207c","analyzedAt":"2026-09-02T03:45:10.400Z","contentChangedAt":null,"schemaVersion":2},"datasetVersion":"2026-09-08T15:18:49.778Z"}