{"record":{"id":"59a5e12123ee9294","repo":"RocketChat/Rocket.Chat","slug":"error-removing-room","errorCode":"error-removing-room","errorMessage":"error-removing-room","messagePattern":"error-removing-room","errorType":"exception","errorClass":"Meteor.Error","httpStatus":null,"severity":"error","filePath":"apps/meteor/server/lib/omnichannel/rooms.ts","lineNumber":311,"sourceCode":"\t\t\t\tvoid notifyOnSubscriptionChanged(doc, 'removed');\n\t\t\t},\n\t\t}),\n\t\tLivechatInquiry.removeByRoomId(rid),\n\t\tLivechatRooms.removeById(rid),\n\t\tReadReceiptsArchive.removeByRoomId(rid),\n\t]);\n\n\tif (result[3]?.status === 'fulfilled' && result[3].value?.deletedCount && inquiry) {\n\t\tvoid notifyOnLivechatInquiryChanged(inquiry, 'removed');\n\t}\n\tif (result[4]?.status === 'fulfilled' && result[4].value?.deletedCount) {\n\t\tvoid notifyOnRoomChanged(room, 'removed');\n\t}\n\n\tfor (const r of result) {\n\t\tif (r.status === 'rejected') {\n\t\t\tlivechatLogger.error({ msg: 'Error removing room', roomId: rid, err: r.reason });\n\t\t\tthrow new Meteor.Error('error-removing-room', 'Error removing room');\n\t\t}\n\t}\n}\n","sourceCodeStart":293,"sourceCodeEnd":315,"githubUrl":"https://github.com/RocketChat/Rocket.Chat/blob/b2c16d5842cbe6b69b59bdf6fc5e5f1afcd1f0b0/apps/meteor/server/lib/omnichannel/rooms.ts#L293-L315","documentation":"Thrown by the omnichannel room cleanup in apps/meteor/server/lib/omnichannel/rooms.ts after a Promise.allSettled over several parallel deletions (subscriptions, inquiry, messages, room document, etc.). If ANY of the settled promises rejected, the code logs 'Error removing room' with the roomId and underlying err.reason, then throws Meteor.Error('error-removing-room'). Fulfilled deletions are NOT rolled back, so the room can end up partially deleted.","triggerScenarios":"Calling omnichannel room removal (e.g. the livechat room-removal flow / Omnichannel queue 'remove room on close' behavior) while one of the MongoDB delete operations fails: subscription removal, message deletion, LivechatInquiry removal, or the LivechatRooms delete itself. Any single rejected promise in the allSettled array triggers it.","commonSituations":"MongoDB connection drop or replica-stepdown mid-cleanup, write timeouts when deleting very large rooms (many messages/subscriptions), disk pressure, or collection/index corruption on one of the involved collections. Retrying the removal usually succeeds because the deletes are idempotent by count.","solutions":["Check the livechatLogger entry { msg: 'Error removing room', roomId, err } — r.reason holds the true cause of the failed stage","Verify MongoDB health (connection, replication lag, disk, slow-query log) at the time of failure","Retry the room removal; already-fulfilled deletes make the retry safe and it will finish the remaining ones","If it fails repeatedly on the same room, inspect that room's documents (orphaned subscriptions, huge message counts) and delete in smaller batches"],"exampleFix":"// before\nawait removeRoom(room); // throws error-removing-room with no visible cause\n\n// after\ntry {\n  await removeRoom(room);\n} catch (err) {\n  if (err?.error === 'error-removing-room') {\n    // r.reason is in server logs; surface roomId for operators\n    console.error('room removal failed, check livechatLogger for', room._id);\n  }\n  throw err;\n}","handlingStrategy":"retry","validationCode":null,"typeGuard":null,"tryCatchPattern":"try {\n  await removeRoom(room);\n} catch (err) {\n  if (err instanceof Meteor.Error && err.error === 'error-removing-room') {\n    // partial deletes are idempotent; inspect livechatLogger for r.reason, then retry once\n    await removeRoom(room);\n  } else {\n    throw err;\n  }\n}","preventionTips":["Alert on livechatLogger 'Error removing room' events to catch partial deletions early","Keep MongoDB healthy (disk, replication lag, timeouts) — most rejections are DB-side write failures","For very large rooms prefer chunked/batched cleanup over one allSettled burst","Treat removal as resumable: rerun the same removal after transient DB failures"],"tags":["omnichannel","meteor","mongodb","room-cleanup","promise-allsettled"],"backgroundTag":"batch-delete-partial-failure","analyzedSha":"b2c16d5842cbe6b69b59bdf6fc5e5f1afcd1f0b0","analyzedAt":"2026-08-18T15:26:39.429Z","contentChangedAt":"2026-08-18T15:26:39.429Z","schemaVersion":2},"datasetVersion":"2026-09-14T00:17:10.932Z"}