{"record":{"id":"83dca8af70b39382","repo":"cube-js/cube","slug":"cube-store-closed-the-connection-closereason","errorCode":null,"errorMessage":"Cube Store closed the connection: ${closeReason || 'message size exceeds the maximum message size Cube Store accepts'}. Reduce the size of the query and of the inline tables it sends, or raise CUBESTORE_TRANSPORT_MAX_MESSAGE_SIZE or CUBESTORE_TRANSPORT_MAX_FRAME_SIZE on the Cube Store side.","messagePattern":"Cube Store closed the connection: (.+?)\\. Reduce the size of the query and of the inline tables it sends, or raise CUBESTORE_TRANSPORT_MAX_MESSAGE_SIZE or CUBESTORE_TRANSPORT_MAX_FRAME_SIZE on the Cube Store side\\.","errorType":"exception","errorClass":"MessageTooLargeError","httpStatus":null,"severity":"error","filePath":"packages/cubejs-cubestore-driver/src/WebSocketConnection.ts","lineNumber":291,"sourceCode":"\n          if (pending.length) {\n            // Cube Store names the size and the limit that refused it here,\n            // which is strictly better than the generic wording, so it\n            // replaces it rather than being appended to it. Peer-supplied\n            // text lands in an error a user reads, so control characters are\n            // folded out and the trailing full stop is normalised rather than\n            // assumed absent. A peer that closes with 1009 and no reason --\n            // an intermediary, or an older Cube Store -- keeps the generic\n            // wording, which is the only reason it still exists.\n            const closeReason = reason?.length\n              // eslint-disable-next-line no-control-regex\n              ? `${reason}`.replace(/[\\u0000-\\u001F\\u007F]+/g, ' ').replace(/\\s*\\.?\\s*$/, '')\n              : '';\n            const fatalError = webSocket.fatalError || (\n              // Cube Store refused a message that didn't fit into its limits.\n              code === MESSAGE_TOO_BIG_CLOSE_CODE ? new MessageTooLargeError(\n                `Cube Store closed the connection: ${closeReason || 'message size exceeds the maximum message size Cube Store accepts'}. `\n                + 'Reduce the size of the query and of the inline tables it sends, or raise '\n                + 'CUBESTORE_TRANSPORT_MAX_MESSAGE_SIZE or CUBESTORE_TRANSPORT_MAX_FRAME_SIZE '\n                + 'on the Cube Store side.'\n              ) : null\n            );\n\n            // The connection multiplexes messages and an oversized one can't be\n            // attributed -- `ws` drops the frame before its message id is read\n            // -- so every message in flight gets one more round, which answers\n            // the innocent ones and usually leaves the offender alone to be\n            // named next time. That includes a message that was alone in\n            // flight: `fatalError` says an oversized frame was seen on this\n            // socket, not which query produced it, and it can be the response\n            // to a query rejected on an earlier round that was still on the\n            // wire. Whatever is still in flight after its round is failed\n            // regardless: an offender whose response keeps arriving before the\n            // other answers would otherwise be re-sent forever.\n            if (fatalError) {\n              // eslint-disable-next-line no-restricted-syntax","sourceCodeStart":273,"sourceCodeEnd":309,"githubUrl":"https://github.com/cube-js/cube/blob/7d981676b36392fec34088b9afab6bdcad40207c/packages/cubejs-cubestore-driver/src/WebSocketConnection.ts#L273-L309","documentation":"Error \"Cube Store closed the connection: ${closeReason || 'message size exceeds the maximum message size Cube Store accepts'}. Reduce the size of the query and of the inline tables it sends, or raise CUBESTORE_TRANSPORT_MAX_MESSAGE_SIZE or CUBESTORE_TRANSPORT_MAX_FRAME_SIZE on the Cube Store side.\" thrown in cube-js/cube.","triggerScenarios":"Thrown at packages/cubejs-cubestore-driver/src/WebSocketConnection.ts:291 when the library encounters an invalid state.","commonSituations":"See trigger scenarios.","solutions":["Reduce the query size and the size of inline tables sent over the WebSocket connection","Raise CUBESTORE_TRANSPORT_MAX_MESSAGE_SIZE and CUBESTORE_TRANSPORT_MAX_FRAME_SIZE on the Cube Store side to accommodate the payload","If the close carried a peer-supplied reason, prefer that specific wording over the generic size-exceeded hypothesis"],"exampleFix":null,"handlingStrategy":"fallback","validationCode":null,"typeGuard":null,"tryCatchPattern":null,"preventionTips":[],"tags":[],"backgroundTag":null,"analyzedSha":"7d981676b36392fec34088b9afab6bdcad40207c","analyzedAt":"2026-09-02T03:45:10.400Z","contentChangedAt":null,"schemaVersion":2},"datasetVersion":"2026-09-08T15:18:49.778Z"}