{"record":{"id":"c5d83dfa77dc76ac","repo":"RocketChat/Rocket.Chat","slug":"error-unserved-rooms-cannot-be-placed-onhold","errorCode":null,"errorMessage":"error-unserved-rooms-cannot-be-placed-onhold","messagePattern":"error-unserved-rooms-cannot-be-placed-onhold","errorType":"exception","errorClass":"Error","httpStatus":null,"severity":"error","filePath":"apps/meteor/ee/server/local-services/omnichannel.internalService.ts","lineNumber":57,"sourceCode":"\n\t\tif (!room || !isOmnichannelRoom(room)) {\n\t\t\tthrow new Error('error-invalid-room');\n\t\t}\n\t\tif (!room.open) {\n\t\t\tthrow new Error('error-room-already-closed');\n\t\t}\n\t\tif (room.onHold) {\n\t\t\tthrow new Error('error-room-is-already-on-hold');\n\t\t}\n\t\tconst restrictedOnHold = settings.get('Livechat_allow_manual_on_hold_upon_agent_engagement_only');\n\t\tconst canRoomBePlacedOnHold = !room.onHold;\n\t\tconst canAgentPlaceOnHold = !room.lastMessage?.token;\n\t\tconst canPlaceChatOnHold = canRoomBePlacedOnHold && (!restrictedOnHold || canAgentPlaceOnHold);\n\t\tif (!canPlaceChatOnHold) {\n\t\t\tthrow new Error('error-cannot-place-chat-on-hold');\n\t\t}\n\t\tif (!room.servedBy) {\n\t\t\tthrow new Error('error-unserved-rooms-cannot-be-placed-onhold');\n\t\t}\n\n\t\tconst [roomResult, subsResult] = await Promise.all([\n\t\t\tLivechatRooms.setOnHoldByRoomId(roomId),\n\t\t\tSubscriptions.setOnHoldByRoomId(roomId),\n\t\t\tMessage.saveSystemMessage<IOmnichannelSystemMessage>('omnichannel_placed_chat_on_hold', roomId, '', onHoldBy, { comment }),\n\t\t]);\n\n\t\tif (roomResult.modifiedCount) {\n\t\t\tvoid notifyOnRoomChangedById(roomId);\n\t\t}\n\n\t\tif (subsResult.modifiedCount) {\n\t\t\tvoid notifyOnSubscriptionChangedByRoomId(roomId);\n\t\t}\n\n\t\tawait callbacks.run('livechat:afterOnHold', room);\n\t}","sourceCodeStart":39,"sourceCodeEnd":75,"githubUrl":"https://github.com/RocketChat/Rocket.Chat/blob/b2c16d5842cbe6b69b59bdf6fc5e5f1afcd1f0b0/apps/meteor/ee/server/local-services/omnichannel.internalService.ts#L39-L75","documentation":"placeRoomOnHold requires an assigned agent: if room.servedBy is unset it throws Error('error-unserved-rooms-cannot-be-placed-onhold'). On-hold semantics depend on the serving agent (resume returns the chat to them), so chats still in queue or whose servedBy was cleared cannot be held.","triggerScenarios":"Attempting to hold a chat that was never taken by an agent (still queued) or whose servedBy was cleared - e.g. the agent was removed, the chat was returned to the queue, or department re-routing reset assignment.","commonSituations":"Bulk on-hold automation sweeping all open rooms including untouched queue items; stale room data missing servedBy; chats returned to queue between the UI read and the hold call.","solutions":["Assign an agent (take the chat) before placing it on hold.","Exclude rooms without servedBy from bulk on-hold operations.","If servedBy was unexpectedly cleared, fix department/agent routing before retrying the hold."],"exampleFix":"// before\nfor (const r of openRooms) await service.placeRoomOnHold(r, comment, user); // queued rooms throw\n\n// after\nfor (const r of openRooms) {\n\tif (!r.servedBy) continue; // unserved/queued chats cannot be held\n\tawait service.placeRoomOnHold(r, comment, user);\n}","handlingStrategy":"validation","validationCode":"if (!room.servedBy) {\n\t// no assigned agent (still queued or assignment cleared); on-hold is not applicable\n}","typeGuard":null,"tryCatchPattern":"try {\n\tawait service.placeRoomOnHold(room, comment, user);\n} catch (e: any) {\n\tif (e?.message === 'error-unserved-rooms-cannot-be-placed-onhold') { surface('Assign an agent before placing the chat on hold'); return; }\n\tthrow e;\n}","preventionTips":["Filter servedBy from room lists used by bulk hold operations.","Ensure chats are taken by an agent before exposing hold actions.","Investigate cleared servedBy values (routing changes) rather than retrying the hold."],"tags":["omnichannel","on-hold","queue","room-state","enterprise"],"backgroundTag":"invalid-room-state","analyzedSha":"b2c16d5842cbe6b69b59bdf6fc5e5f1afcd1f0b0","analyzedAt":"2026-08-18T15:26:39.429Z","contentChangedAt":"2026-08-18T15:26:39.429Z","schemaVersion":2},"datasetVersion":"2026-09-23T08:17:48.524Z"}