RocketChat/Rocket.Chat · error · Meteor.Error

error-app-prevented

error-app-prevented

Error message

error-app-prevented

What it means

Rocket.Chat Apps can subscribe to the IPreLivechatRoomCreatePrevent lifecycle event and veto livechat room creation. When such an App throws an AppsEngineException during QueueManager.requestRoom, the server rethrows it as Meteor.Error('error-app-prevented') carrying the App's own message. The room, its inquiry, and the conversation are never created.

Source

Thrown at apps/meteor/server/lib/omnichannel/QueueManager.ts:366

			if (!defaultAgent && guest.department && !department) {
				throw new Meteor.Error('no-agent-online', 'Sorry, no online agents');
			}

			if (!agent && !guest.department && !(await checkOnlineAgents())) {
				throw new Meteor.Error('no-agent-online', 'Sorry, no online agents');
			}
		}

		const insertionRoom = await prepareLivechatRoom(rid, { ...guest, ...(department && { department }) }, roomInfo, {
			...extraData,
			...(Boolean(customFields) && { customFields }),
		});

		try {
			await Apps.self?.triggerEvent(AppEvents.IPreLivechatRoomCreatePrevent, insertionRoom);
		} catch (error: any) {
			if (error.name === AppsEngineException.name) {
				throw new Meteor.Error('error-app-prevented', error.message);
			}

			throw error;
		}

		// Transactional start of the conversation. This should prevent rooms from being created without inquiries and viceversa.
		// All the actions that happened inside createLivechatRoom are now outside this transaction
		const { room, inquiry } = await this.startConversation(rid, insertionRoom, guest, roomInfo, defaultAgent, message, extraData);

		await onNewRoom(room);
		await Message.saveSystemMessageAndNotifyUser(
			'livechat-started',
			rid,
			'',
			{ _id: guest._id, username: guest.username },
			{ groupable: false, token: guest.token },
		);
		void Apps.self?.triggerEvent(AppEvents.IPostLivechatRoomStarted, room);

View on GitHub (pinned to 2a7de45707)

Solutions

  1. Read error.message (or error.reason) - it is the App's own explanation of why creation was prevented
  2. Inspect installed Apps (Administration > Apps), find the one listening on IPreLivechatRoomCreatePrevent, and adjust its configuration or prevent conditions
  3. Disable or uninstall the offending app if the veto is unwanted
  4. Update the app's code to stop preventing this specific scenario
Defensive patterns

Strategy: try-catch

Try / catch

try {
  await QueueManager.requestRoom({ guest, roomInfo });
} catch (err: any) {
  if (err?.error === 'error-app-prevented') {
    // err.message / err.reason carries the App's own explanation
    logger.warn({ msg: 'Livechat room creation vetoed by app', reason: err.message });
    return respondForbidden(err.message);
  }
  throw err;
}

Prevention

When it happens

Trigger: Any installed App whose IPreLivechatRoomCreatePrevent handler calls preventResult()/throws - e.g. a moderation app blocking banned visitors, or a custom policy app rejecting rooms that lack required custom fields - while a livechat room is being created for a guest.

Common situations: A marketplace or private app enforcing company policy on new chats; an app update made its validation stricter and now rejects rooms that previously passed; a leftover enabled app silently vetoing all new omnichannel rooms after a process change.

Related errors


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