RocketChat/Rocket.Chat · warning · Meteor.Error

error-inquiry-taken

error-inquiry-taken

Error message

error-inquiry-taken

What it means

takeInquiry refuses to grab an inquiry whose status is already 'taken': it throws Meteor.Error('error-inquiry-taken', 'Inquiry already taken', { method: 'livechat:takeInquiry' }). This is the deliberate concurrency guard for two agents claiming the same queued conversation — the document's status field is the source of truth, checked before the room is reassigned.

Source

Thrown at apps/meteor/server/lib/omnichannel/takeInquiry.ts:24

import { isAgentAvailableToTakeContactInquiry } from './contacts/isAgentAvailableToTakeContactInquiry';
import { migrateVisitorIfMissingContact } from './contacts/migrateVisitorIfMissingContact';
import { settings } from '../../settings';

export const takeInquiry = async (
	userId: string,
	inquiryId: string,
	options?: { clientAction: boolean; forwardingToDepartment?: { oldDepartmentId: string; transferData: any } },
): Promise<void> => {
	const inquiry = await LivechatInquiry.findOneById(inquiryId);

	if (!inquiry) {
		throw new Meteor.Error('error-not-found', 'Inquiry not found', {
			method: 'livechat:takeInquiry',
		});
	}

	if (inquiry.status === 'taken') {
		throw new Meteor.Error('error-inquiry-taken', 'Inquiry already taken', {
			method: 'livechat:takeInquiry',
		});
	}

	const user = await Users.findOneOnlineAgentById(
		userId,
		settings.get<boolean>('Livechat_enabled_when_agent_idle'),
		settings.get<boolean>('Livechat_accept_chats_with_no_agents'),
		{},
	);
	if (!user) {
		throw new Meteor.Error('error-agent-status-service-offline', 'Agent status is offline or Omnichannel service is not active', {
			method: 'livechat:takeInquiry',
			...(process.env.TEST_MODE && {
				Livechat_enabled_when_agent_idle: settings.get<boolean>('Livechat_enabled_when_agent_idle'),
				Livechat_accept_chats_with_no_agents: settings.get<boolean>('Livechat_accept_chats_with_no_agents'),
				user: await Users.findOneById(userId),
			}),

View on GitHub (pinned to b2c16d5842)

Solutions

  1. Treat 'error-inquiry-taken' as a normal outcome: catch it, update the local queue, and move on — do not blindly retry
  2. Guard the take button against double-clicks while a take request is in flight
  3. Subscribe to the livechat inquiry stream so taken entries disappear immediately from all clients
  4. On retry-after-timeout, first re-fetch the inquiry status instead of re-taking

Example fix

// before
await Meteor.callAsync('livechat:takeInquiry', inquiryId);

// after
try {
  await Meteor.callAsync('livechat:takeInquiry', inquiryId);
} catch (err) {
  if (err?.error === 'error-inquiry-taken') return removeInquiryLocally(inquiryId);
  throw err;
}
Defensive patterns

Strategy: try-catch

Validate before calling

import { LivechatInquiry } from '@rocket.chat/models';

const inquiry = await LivechatInquiry.findOneById(inquiryId);
if (inquiry?.status === 'taken') {
  return removeInquiryLocally(inquiryId); // lost the race; nothing to do
}
await Meteor.callAsync('livechat:takeInquiry', inquiryId);

Type guard

function isTakeableInquiry(v: { status?: string } | null | undefined): v is { _id: string; status: 'queued' } {
  return !!v && v.status === 'queued';
}

Try / catch

try {
  await Meteor.callAsync('livechat:takeInquiry', inquiryId);
} catch (err) {
  if (err instanceof Meteor.Error && err.error === 'error-inquiry-taken') {
    // expected race outcome: drop the entry from the UI, do NOT retry the take
  } else {
    throw err;
  }
}

Prevention

When it happens

Trigger: Two agents (or an agent and an auto-assignment routine) call livechat:takeInquiry for the same inquiry within the same window; the loser of the race reads status 'taken' and gets this error. Also a single client double-clicking take, or a retry after a slow first call that actually succeeded.

Common situations: High-traffic queues where several agents click the same lead, duplicate submissions from flaky UIs, retries that don't check whether the first take succeeded, bots racing human agents.

Related errors


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