{"record":{"id":"2feee05dd97544bf","repo":"RocketChat/Rocket.Chat","slug":"error-message-size-exceeded-2feee0","errorCode":"error-message-size-exceeded","errorMessage":"Message size exceeds Message_MaxAllowedSize","messagePattern":"Message size exceeds Message_MaxAllowedSize","errorType":"exception","errorClass":"Meteor.Error","httpStatus":null,"severity":"error","filePath":"apps/meteor/server/meteor-methods/messages/sendMessage.ts","lineNumber":68,"sourceCode":"\tconst now = new Date();\n\tmessage.ts = extraInfo?.ts ?? message.ts ?? now;\n\tif (isTimestampFromClient) {\n\t\tconst tsDiff = Math.abs(moment(message.ts).diff(Date.now()));\n\t\tif (tsDiff > 60000) {\n\t\t\tthrow new Meteor.Error('error-message-ts-out-of-sync', 'Message timestamp is out of sync', {\n\t\t\t\tmethod: 'sendMessage',\n\t\t\t\tmessage_ts: message.ts,\n\t\t\t\tserver_ts: new Date().getTime(),\n\t\t\t});\n\t\t}\n\t\tif (tsDiff > 10000) {\n\t\t\tmessage.ts = now;\n\t\t}\n\t}\n\n\tif (message.msg) {\n\t\tif (message.msg.length > (settings.get<number>('Message_MaxAllowedSize') ?? 0)) {\n\t\t\tthrow new Meteor.Error('error-message-size-exceeded', 'Message size exceeds Message_MaxAllowedSize', {\n\t\t\t\tmethod: 'sendMessage',\n\t\t\t});\n\t\t}\n\t}\n\n\tconst user = typeof uid === 'string' ? await Users.findOneById(uid) : uid;\n\tif (!user?.username) {\n\t\tthrow new Meteor.Error('error-invalid-user', 'Invalid user');\n\t}\n\n\tlet { rid } = message;\n\n\t// do not allow nested threads\n\tif (message.tmid) {\n\t\tconst parentMessage = await Messages.findOneById(message.tmid, { projection: { rid: 1, tmid: 1 } });\n\t\tmessage.tmid = parentMessage?.tmid || message.tmid;\n\n\t\tif (parentMessage?.rid) {","sourceCodeStart":50,"sourceCodeEnd":86,"githubUrl":"https://github.com/RocketChat/Rocket.Chat/blob/b2c16d5842cbe6b69b59bdf6fc5e5f1afcd1f0b0/apps/meteor/server/meteor-methods/messages/sendMessage.ts#L50-L86","documentation":"If message.msg is non-empty and its length exceeds the Message_MaxAllowedSize setting, executeSendMessage throws error-message-size-exceeded before the sender or room is even resolved. The limit is a workspace-wide setting (default 5000 characters) applied to the raw message body.","triggerScenarios":"Pasting a large log, stack trace or generated blob into the message; bots posting untruncated content; lowering Message_MaxAllowedSize and then editing/replaying older, longer messages.","commonSituations":"Support tooling pasting whole logs; AI/integration output exceeding the default; admin tightened the limit and existing drafts now fail on send.","solutions":["Truncate or split the payload client-side before sending, respecting Message_MaxAllowedSize","Raise Message_MaxAllowedSize in Admin -> Message if the use case genuinely needs larger bodies","For large content use a file upload or attachment link instead of the message text"],"exampleFix":"// before\nawait Meteor.callAsync('sendMessage', { rid, msg: hugeText });\n\n// after: enforce the limit client-side\nconst max = settings.get('Message_MaxAllowedSize') ?? 5000;\nconst msg = hugeText.length > max ? `${hugeText.slice(0, max - 3)}...` : hugeText;\nawait Meteor.callAsync('sendMessage', { rid, msg });","handlingStrategy":"validation","validationCode":"// client: enforce the workspace limit before sending\nconst max = settings.get<number>('Message_MaxAllowedSize') ?? 5000;\nconst msg = body.length > max ? `${body.slice(0, max - 1)}\\u2026` : body;\nawait Meteor.callAsync('sendMessage', { rid, msg });","typeGuard":null,"tryCatchPattern":"try {\n\tawait Meteor.callAsync('sendMessage', { rid, msg: body });\n} catch (e: any) {\n\tif (e?.error === 'error-message-size-exceeded') {\n\t\t// split into chunks or upload as a file instead of retrying the same body\n\t}\n\tthrow e;\n}","preventionTips":["Read Message_MaxAllowedSize from the settings subscription and cap the composer","Show a live character counter near the limit","Route oversized content (logs, dumps) to file upload, not the message body"],"tags":["meteor-method","messages","payload-size","settings"],"backgroundTag":"payload-too-large","analyzedSha":"b2c16d5842cbe6b69b59bdf6fc5e5f1afcd1f0b0","analyzedAt":"2026-08-18T15:26:39.429Z","schemaVersion":2},"datasetVersion":"2026-08-21T18:17:14.833Z"}