{"record":{"id":"437e33311ac7b33f","repo":"RocketChat/Rocket.Chat","slug":"error-verifying-contact-channel","errorCode":null,"errorMessage":"error-verifying-contact-channel","messagePattern":"error-verifying-contact-channel","errorType":"exception","errorClass":"Error","httpStatus":null,"severity":"error","filePath":"apps/meteor/ee/server/patches/verifyContactChannel.ts","lineNumber":53,"sourceCode":"\t\tawait LivechatContacts.updateFromUpdaterByAssociation({ visitorId, source: room.source }, updater, { session });\n\n\t\tawait LivechatRooms.update({ _id: roomId }, { $set: { verified: true } }, { session });\n\t\tlogger.debug({ msg: 'Merging contacts', contactId, visitorId, roomId });\n\n\t\tconst mergeContactsResult = await mergeContacts(contactId, { visitorId, source: room.source }, session);\n\n\t\tawait session.commitTransaction();\n\n\t\treturn mergeContactsResult;\n\t} catch (e) {\n\t\tawait session.abortTransaction();\n\t\tif (shouldRetryTransaction(e) && attempts > 0) {\n\t\t\tlogger.debug({ msg: 'Retrying to verify contact channel', contactId, visitorId, roomId });\n\t\t\treturn _verifyContactChannel(params, room, attempts - 1);\n\t\t}\n\n\t\tlogger.error({ msg: 'Error verifying contact channel', contactId, visitorId, roomId, error: e });\n\t\tthrow new Error('error-verifying-contact-channel');\n\t} finally {\n\t\tawait session.endSession();\n\t}\n}\n\nexport const runVerifyContactChannel = async (\n\t_next: any,\n\tparams: {\n\t\tcontactId: string;\n\t\tfield: string;\n\t\tvalue: string;\n\t\tvisitorId: string;\n\t\troomId: string;\n\t},\n): Promise<ILivechatContact | null> => {\n\tconst { roomId, contactId, visitorId } = params;\n\n\tconst room = await LivechatRooms.findOneById(roomId);","sourceCodeStart":35,"sourceCodeEnd":71,"githubUrl":"https://github.com/RocketChat/Rocket.Chat/blob/f9d3ec372bb580fa8d036f94cf03925a478ef768/apps/meteor/ee/server/patches/verifyContactChannel.ts#L35-L71","documentation":"Thrown by _verifyContactChannel when the MongoDB transaction that updates the contact, marks the room verified, and merges contacts fails and cannot be retried. The function already retries twice on transient errors (shouldRetryTransaction), so this error means the transaction genuinely failed (write conflict that exhausted retries, validation error, or a non-transient fault). The catch aborts the transaction, logs the underlying error, and re-throws this generic Error.","triggerScenarios":"A write conflict (WriteConflict/error code 112) that survives both retries; a MongoDB transaction abort due to a constraint/validation failure inside the transaction; loss of the replica-set primary mid-transaction; an error thrown by mergeContacts inside the transaction that is not retryable.","commonSituations":"High concurrency on the same visitor/contact causing repeated write conflicts; MongoDB standalone (no replica set) where transactions are unsupported; long-running transactions hitting the 60s default timeout; schema validator rejecting the update query.","solutions":["Inspect the logged 'error: e' in the server log to find the underlying MongoDB error code.","For write conflicts, reduce contention on the same contact/visitor or increase the retry count / back-off.","Ensure the deployment runs a replica set (required for multi-document transactions).","For validation errors, fix the data shape produced by setVerifiedUpdateQuery/setFieldAndValueUpdateQuery."],"exampleFix":null,"handlingStrategy":"retry","validationCode":null,"typeGuard":null,"tryCatchPattern":"try {\n  await verifyContactChannel(params);\n} catch (e) {\n  if (e.message === 'error-verifying-contact-channel') {\n    // surface a generic 'verification failed, please retry' and log correlation id\n  } else throw e;\n}","preventionTips":["Run MongoDB as a replica set so multi-document transactions are supported.","Reduce contention on the same visitor/contact to lower write-conflict retries.","Inspect server logs for the underlying transaction error code (112, etc.).","Keep transactions short to stay under the 60s default timeout."],"tags":["omnichannel","contacts","transactions","mongodb","retry"],"backgroundTag":null,"analyzedSha":"f9d3ec372bb580fa8d036f94cf03925a478ef768","analyzedAt":"2026-08-12T19:07:17.372Z","schemaVersion":2},"datasetVersion":"2026-08-12T23:17:12.415Z"}