RocketChat/Rocket.Chat · error · Error

failed-to-create-livechat-call

Error message

failed-to-create-livechat-call

What it means

Livechat variant: VideoConferenceModel.createLivechat returned an id, but the immediate getUnfiltered(callId) read - which happens before runNewVideoConferenceEvent in this branch - yields null. No app event has run yet, so the cause is narrower than the direct/group cases: the insert itself failed to persist, a model hook removed it, or the read could not see the just-written document.

Source

Thrown at apps/meteor/server/services/video-conference/service.ts:870

			callId,
			rid,
		};
	}

	private async startLivechat(providerName: string, user: IUser, rid: IRoom['_id']): Promise<LivechatInstructions> {
		const callId = await VideoConferenceModel.createLivechat({
			rid,
			createdBy: {
				_id: user._id,
				name: user.name as string,
				username: user.username as string,
			},
			providerName,
		});

		const call = (await this.getUnfiltered(callId)) as ILivechatVideoConference | null;
		if (!call) {
			throw new Error('failed-to-create-livechat-call');
		}

		await this.runNewVideoConferenceEvent(callId);

		// Livechat conferences do not use discussions

		const joinUrl = await this.getUrl(call);
		const messageId = await this.createLivechatMessage(call, user, joinUrl);
		call.messages.started = messageId;
		await VideoConferenceModel.setMessageById(callId, 'started', messageId);

		return {
			type: 'livechat',
			callId,
		};
	}

	private async joinCall(

View on GitHub (pinned to e4b8178b20)

Solutions

  1. Confirm createLivechat actually inserted (check the returned id in the video_conference collection and server logs for write errors)
  2. Remove or fix collection hooks that delete livechat call documents
  3. Ensure the read after create targets the primary (or waits for write visibility) in replica-set deployments
  4. Retry the livechat call start after fixing the write path

Example fix

// before
const call = (await this.getUnfiltered(callId)) as ILivechatVideoConference | null;
if (!call) throw new Error('failed-to-create-livechat-call');

// after - keep the guard, but make the write verifiable
const callId = await VideoConferenceModel.createLivechat({ rid, createdBy, providerName });
if (!callId) throw new Error('failed-to-create-livechat-call'); // write returned no id
const call = (await this.getUnfiltered(callId)) as ILivechatVideoConference | null;
if (!call) throw new Error('failed-to-create-livechat-call'); // read lost the doc
Defensive patterns

Strategy: try-catch

Try / catch

try {
	await videoConfService.startLivechatCall(user, rid);
} catch (err) {
	if (err instanceof Error && err.message === 'failed-to-create-livechat-call') {
		// verify the insert persisted; check DB write errors and collection hooks
	}
}

Prevention

When it happens

Trigger: Starting a livechat video call when the video_conference insert silently fails or is rolled back; a collection hook deleting livechat call docs; a replica-set read routed away from the node that took the write.

Common situations: Disk/capacity problems causing failed writes on the calls collection; custom hooks registered on video_conference for livechat; deployments where reads hit lagging secondaries.

Related errors


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