RocketChat/Rocket.Chat · error · Meteor.Error

error-message-size-exceeded

error-message-size-exceeded

Error message

Message size exceeds Message_MaxAllowedSize

What it means

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.

Source

Thrown at apps/meteor/server/meteor-methods/messages/sendMessage.ts:68

	const now = new Date();
	message.ts = extraInfo?.ts ?? message.ts ?? now;
	if (isTimestampFromClient) {
		const tsDiff = Math.abs(moment(message.ts).diff(Date.now()));
		if (tsDiff > 60000) {
			throw new Meteor.Error('error-message-ts-out-of-sync', 'Message timestamp is out of sync', {
				method: 'sendMessage',
				message_ts: message.ts,
				server_ts: new Date().getTime(),
			});
		}
		if (tsDiff > 10000) {
			message.ts = now;
		}
	}

	if (message.msg) {
		if (message.msg.length > (settings.get<number>('Message_MaxAllowedSize') ?? 0)) {
			throw new Meteor.Error('error-message-size-exceeded', 'Message size exceeds Message_MaxAllowedSize', {
				method: 'sendMessage',
			});
		}
	}

	const user = typeof uid === 'string' ? await Users.findOneById(uid) : uid;
	if (!user?.username) {
		throw new Meteor.Error('error-invalid-user', 'Invalid user');
	}

	let { rid } = message;

	// do not allow nested threads
	if (message.tmid) {
		const parentMessage = await Messages.findOneById(message.tmid, { projection: { rid: 1, tmid: 1 } });
		message.tmid = parentMessage?.tmid || message.tmid;

		if (parentMessage?.rid) {

View on GitHub (pinned to b2c16d5842)

Solutions

  1. Truncate or split the payload client-side before sending, respecting Message_MaxAllowedSize
  2. Raise Message_MaxAllowedSize in Admin -> Message if the use case genuinely needs larger bodies
  3. For large content use a file upload or attachment link instead of the message text

Example fix

// before
await Meteor.callAsync('sendMessage', { rid, msg: hugeText });

// after: enforce the limit client-side
const max = settings.get('Message_MaxAllowedSize') ?? 5000;
const msg = hugeText.length > max ? `${hugeText.slice(0, max - 3)}...` : hugeText;
await Meteor.callAsync('sendMessage', { rid, msg });
Defensive patterns

Strategy: validation

Validate before calling

// client: enforce the workspace limit before sending
const max = settings.get<number>('Message_MaxAllowedSize') ?? 5000;
const msg = body.length > max ? `${body.slice(0, max - 1)}\u2026` : body;
await Meteor.callAsync('sendMessage', { rid, msg });

Try / catch

try {
	await Meteor.callAsync('sendMessage', { rid, msg: body });
} catch (e: any) {
	if (e?.error === 'error-message-size-exceeded') {
		// split into chunks or upload as a file instead of retrying the same body
	}
	throw e;
}

Prevention

When it happens

Trigger: 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.

Common situations: Support tooling pasting whole logs; AI/integration output exceeding the default; admin tightened the limit and existing drafts now fail on send.

Related errors


AI-assisted analysis of RocketChat/Rocket.Chat@b2c16d5842 (2026-08-18). Data as JSON: /api/errors/2feee05dd97544bf. Report an issue: GitHub.