RocketChat/Rocket.Chat · error · Meteor.Error
error-removing-visitor
error-removing-visitor
Error message
An error ocurred while deleting visitor
What it means
Thrown by DELETE /api/v1/livechat/visitor/:token when removeContactsByVisitorId() throws while deleting the visitor's contact records. The visitor lookup and open-rooms check already passed, so this is a failure inside the deletion transaction itself. The original exception is logged (livechatLogger.error with msg 'Error removing visitor') before this generic error-livechat-removing-visitor is raised.
Solutions
- Read the server log entry 'Error removing visitor' — the logged err field holds the actual Mongo error to act on
- Retry the DELETE after the underlying DB issue clears (check Mongo health, disk, oplog)
- If a specific contact document is corrupted, fix or remove it directly in the livechat_contacts collection, then retry
- Verify the DB user has remove permissions on the contacts collection
Defensive patterns
Strategy: try-catch
Try / catch
const body = await (await fetch(`${server}/api/v1/livechat/visitor/${token}`, { method: 'DELETE' })).json();
if (!body.success && body.error === 'error-removing-visitor') {
// server log 'Error removing visitor' holds the root cause; safe to retry after DB check
await notifyOps('visitor deletion failed — check livechatLogger');
} Prevention
- Retry once after confirming DB health — the underlying removeContactsByVisitorId failure is often transient
- Alert ops with the rid/token so they can pull the logged err detail
- Keep contact collections indexed and healthy for large-scale deletions
When it happens
Trigger: Mongo write failure or timeout while removing linked contact documents; corrupted contact references (visitor id present in contacts but document shape unexpected); database permission/lock issues during peak load.
Common situations: Large visitors with many contact records timing out; replica set step-down mid-delete; partial deletes leaving orphaned contact entries that fail subsequent cleanup.
Related errors
- error-invalid-channel
- error-verifying-contact-channel
- visitor-has-open-rooms
- error-contact-channel-blocked
- error-contact-has-no-conflicts
AI-assisted analysis of RocketChat/Rocket.Chat@b2c16d5842 (2026-08-18).
Data as JSON: /api/errors/d7dc5f038e2149ce.
Report an issue: GitHub.
Appendix: source
Thrown at apps/meteor/server/api/v1/omnichannel/visitor.ts:158
).toArray();
// if gdpr is enabled, bypass rooms check
if (rooms?.length && !settings.get('Livechat_Allow_collect_and_store_HTTP_header_informations')) {
throw new Meteor.Error('visitor-has-open-rooms', 'Cannot remove visitors with opened rooms');
}
const { _id } = visitor;
try {
await removeContactsByVisitorId({ _id });
return API.v1.success({
visitor: {
_id,
ts: new Date().toISOString(),
},
});
} catch (e) {
livechatLogger.error({ msg: 'Error removing visitor', err: e });
throw new Meteor.Error('error-removing-visitor', 'An error ocurred while deleting visitor');
}
},
});
API.v1.addRoute(
'livechat/visitor/:token/room',
{ authRequired: true, permissionsRequired: ['view-livechat-manager'] },
{
async get() {
const extraQuery = await callbacks.run('livechat.applyRoomRestrictions', {}, { userId: this.userId });
const rooms = await LivechatRooms.findOpenByVisitorToken(
this.urlParams.token,
{
projection: {
name: 1,
t: 1,
cl: 1,
u: 1,View on GitHub (pinned to b2c16d5842)