{"record":{"id":"d7dc5f038e2149ce","repo":"RocketChat/Rocket.Chat","slug":"error-removing-visitor","errorCode":"error-removing-visitor","errorMessage":"An error ocurred while deleting visitor","messagePattern":"An error ocurred while deleting visitor","errorType":"exception","errorClass":"Meteor.Error","httpStatus":null,"severity":"error","filePath":"apps/meteor/server/api/v1/omnichannel/visitor.ts","lineNumber":158,"sourceCode":"\t\t).toArray();\n\n\t\t// if gdpr is enabled, bypass rooms check\n\t\tif (rooms?.length && !settings.get('Livechat_Allow_collect_and_store_HTTP_header_informations')) {\n\t\t\tthrow new Meteor.Error('visitor-has-open-rooms', 'Cannot remove visitors with opened rooms');\n\t\t}\n\n\t\tconst { _id } = visitor;\n\t\ttry {\n\t\t\tawait removeContactsByVisitorId({ _id });\n\t\t\treturn API.v1.success({\n\t\t\t\tvisitor: {\n\t\t\t\t\t_id,\n\t\t\t\t\tts: new Date().toISOString(),\n\t\t\t\t},\n\t\t\t});\n\t\t} catch (e) {\n\t\t\tlivechatLogger.error({ msg: 'Error removing visitor', err: e });\n\t\t\tthrow new Meteor.Error('error-removing-visitor', 'An error ocurred while deleting visitor');\n\t\t}\n\t},\n});\n\nAPI.v1.addRoute(\n\t'livechat/visitor/:token/room',\n\t{ authRequired: true, permissionsRequired: ['view-livechat-manager'] },\n\t{\n\t\tasync get() {\n\t\t\tconst extraQuery = await callbacks.run('livechat.applyRoomRestrictions', {}, { userId: this.userId });\n\t\t\tconst rooms = await LivechatRooms.findOpenByVisitorToken(\n\t\t\t\tthis.urlParams.token,\n\t\t\t\t{\n\t\t\t\t\tprojection: {\n\t\t\t\t\t\tname: 1,\n\t\t\t\t\t\tt: 1,\n\t\t\t\t\t\tcl: 1,\n\t\t\t\t\t\tu: 1,","sourceCodeStart":140,"sourceCodeEnd":176,"githubUrl":"https://github.com/RocketChat/Rocket.Chat/blob/f9d3ec372bb580fa8d036f94cf03925a478ef768/apps/meteor/server/api/v1/omnichannel/visitor.ts#L140-L176","documentation":"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.","triggerScenarios":"removeContactsByVisitorId fails - e.g. a DB write error during contact cleanup, a locked document, a model-layer validation failure, or an injected dependency throwing.","commonSituations":"Mongo transaction abort during contact removal; an omnichannel plugin hook into contact deletion raising; network blip to the DB.","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."],"exampleFix":"null","handlingStrategy":"try-catch","validationCode":"null","typeGuard":"null","tryCatchPattern":"try {\n  await fetch(url, { method: 'DELETE' });\n} catch (e) {\n  if (e.error === 'error-removing-visitor') {\n    // surface to operator; original cause is in server logs only\n    notifyOpsTeam('visitor deletion failed, see logs');\n  }\n  throw e;\n}","preventionTips":["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."],"tags":["omnichannel","visitor","delete","contacts","logging"],"backgroundTag":null,"analyzedSha":"f9d3ec372bb580fa8d036f94cf03925a478ef768","analyzedAt":"2026-08-12T19:07:17.372Z","schemaVersion":2},"datasetVersion":"2026-08-12T23:17:12.415Z"}