RocketChat/Rocket.Chat · error · Meteor.Error
error-removing-room
error-removing-room
Error message
error-removing-room
What it means
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.
Source
Thrown at apps/meteor/server/lib/omnichannel/rooms.ts:311
void notifyOnSubscriptionChanged(doc, 'removed');
},
}),
LivechatInquiry.removeByRoomId(rid),
LivechatRooms.removeById(rid),
ReadReceiptsArchive.removeByRoomId(rid),
]);
if (result[3]?.status === 'fulfilled' && result[3].value?.deletedCount && inquiry) {
void notifyOnLivechatInquiryChanged(inquiry, 'removed');
}
if (result[4]?.status === 'fulfilled' && result[4].value?.deletedCount) {
void notifyOnRoomChanged(room, 'removed');
}
for (const r of result) {
if (r.status === 'rejected') {
livechatLogger.error({ msg: 'Error removing room', roomId: rid, err: r.reason });
throw new Meteor.Error('error-removing-room', 'Error removing room');
}
}
}
View on GitHub (pinned to b2c16d5842)
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
Example fix
// before
await removeRoom(room); // throws error-removing-room with no visible cause
// after
try {
await removeRoom(room);
} catch (err) {
if (err?.error === 'error-removing-room') {
// r.reason is in server logs; surface roomId for operators
console.error('room removal failed, check livechatLogger for', room._id);
}
throw err;
} Defensive patterns
Strategy: retry
Try / catch
try {
await removeRoom(room);
} catch (err) {
if (err instanceof Meteor.Error && err.error === 'error-removing-room') {
// partial deletes are idempotent; inspect livechatLogger for r.reason, then retry once
await removeRoom(room);
} else {
throw err;
}
} Prevention
- 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
When it happens
Trigger: 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.
Common situations: 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.
Related errors
- error-invalid-visitor
- error-room-cannot-be-closed-try-again
- error-failed-to-delete-department
- error-invalid-user
- Invalid command parameter provided, must be a string.
AI-assisted analysis of RocketChat/Rocket.Chat@b2c16d5842 (2026-08-18).
Data as JSON: /api/errors/59a5e12123ee9294.
Report an issue: GitHub.