RocketChat/Rocket.Chat · error · Meteor.Error
error-removing-visitor
error-removing-visitor
Error message
An error ocurred while deleting visitor
What it means
Thrown as Meteor.Error('error-removing-visitor', 'An error ocurred while deleting visitor') when removeContactsByVisitorId({ _id }) throws inside the try block of DELETE livechat/visitor/:token. The original exception is logged via livechatLogger.error and a generic message is re-thrown, so the root cause is only visible in server logs.
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 f9d3ec372b)
Solutions
- Inspect the server log entry 'Error removing visitor' for the original err object.
- Retry the delete once the underlying DB issue resolves.
- Verify removeContactsByVisitorId has no plugin callbacks raising for this visitor's contact records.
Example fix
null
Defensive patterns
Strategy: try-catch
Validate before calling
null
Type guard
null
Try / catch
try {
await fetch(url, { method: 'DELETE' });
} catch (e) {
if (e.error === 'error-removing-visitor') {
// surface to operator; original cause is in server logs only
notifyOpsTeam('visitor deletion failed, see logs');
}
throw e;
} Prevention
- Capture the server-side 'Error removing visitor' log line for the real cause.
- Retry after resolving the underlying DB/contact issue.
- Audit omnichannel contact-deletion callbacks for plugins that raise.
When it happens
Trigger: removeContactsByVisitorId fails - e.g. a DB write error during contact cleanup, a locked document, a model-layer validation failure, or an injected dependency throwing.
Common situations: Mongo transaction abort during contact removal; an omnichannel plugin hook into contact deletion raising; network blip to the DB.
Related errors
- visitor-has-open-rooms
- error-contact-not-found
- error-action-not-allowed
- error-invalid-contact
- error-invalid-channel
AI-assisted analysis of RocketChat/Rocket.Chat@f9d3ec372b (2026-08-12).
Data as JSON: /api/errors/d7dc5f038e2149ce.
Report an issue: GitHub.