{"record":{"id":"5e9366e1f8921ff8","repo":"RocketChat/Rocket.Chat","slug":"room-not-found-5e9366","errorCode":null,"errorMessage":"Room not found","messagePattern":"Room not found","errorType":"exception","errorClass":"Error","httpStatus":null,"severity":"error","filePath":"apps/meteor/client/lib/chats/data.ts","lineNumber":268,"sourceCode":"\tconst drafts = new Map<IMessage['_id'] | undefined, string>();\n\n\tconst getDraft = async (mid: IMessage['_id'] | undefined): Promise<string | undefined> => drafts.get(mid);\n\n\tconst discardDraft = async (mid: IMessage['_id'] | undefined): Promise<void> => {\n\t\tdrafts.delete(mid);\n\t};\n\n\tconst saveDraft = async (mid: IMessage['_id'] | undefined, draft: string): Promise<void> => {\n\t\tdrafts.set(mid, draft);\n\t};\n\n\tconst findRoom = async (): Promise<IRoom | undefined> => Rooms.state.get(rid);\n\n\tconst getRoom = async (): Promise<IRoom> => {\n\t\tconst room = await findRoom();\n\n\t\tif (!room) {\n\t\t\tthrow new Error('Room not found');\n\t\t}\n\n\t\treturn room;\n\t};\n\n\tconst isSubscribedToRoom = async (): Promise<boolean> => !!Subscriptions.state.find((record) => record.rid === rid);\n\n\tconst joinRoom = async (): Promise<void> => {\n\t\tawait sdk.rest.post('/v1/rooms.join', { roomId: rid });\n\t};\n\n\tconst findDiscussionByID = async (drid: IRoom['_id']): Promise<IRoom | undefined> =>\n\t\tRooms.state.find((record) => Boolean(record._id === drid && record.prid));\n\n\tconst getDiscussionByID = async (drid: IRoom['_id']): Promise<IRoom> => {\n\t\tconst discussion = await findDiscussionByID(drid);\n\n\t\tif (!discussion) {","sourceCodeStart":250,"sourceCodeEnd":286,"githubUrl":"https://github.com/RocketChat/Rocket.Chat/blob/f9d3ec372bb580fa8d036f94cf03925a478ef768/apps/meteor/client/lib/chats/data.ts#L250-L286","documentation":"Thrown by getRoom, the strict getter that wraps findRoom. findRoom reads from the local Rooms state store (a client-side reactive cache keyed by room ID). If the room record is not present in that store, getRoom throws. This is a data layer function scoped to a specific rid (the chat context's room ID).","triggerScenarios":"The room data has not been loaded into the Rooms store yet (e.g., deep-linked directly to a room before subscription data arrives). The user is not a member of the room and the room metadata was never fetched. The room was deleted and its record removed from the store. Race condition: code calls getRoom before the initial subscriptions/rooms sync completes.","commonSituations":"Direct URL navigation to a room the user has not visited in this session. Room was archived/deleted while the user had the client open. Multi-tab scenario where another tab caused a store reset.","solutions":["Switch to findRoom() which returns undefined instead of throwing, and handle absence gracefully (show loading state, retry after sync).","Ensure the Rooms store is hydrated before calling getRoom — wait for the subscription/rooms stream to complete initial load.","Catch the error at the call site and trigger a room fetch from the server, then retry.","Validate that the user is subscribed to the room before accessing it."],"exampleFix":"// before\nconst room = await getRoom();\n// after\nconst room = await findRoom();\nif (!room) {\n  await fetchRoomFromServer(rid);\n  return;\n}","handlingStrategy":"validation","validationCode":"const room = await findRoom();\nif (!room) {\n  // wait for store hydration or fetch from server\n  await fetchRoomData(rid);\n  return;\n}\n// proceed with room data","typeGuard":"const roomExistsInStore = async (): Promise<boolean> => {\n  return Boolean(await Rooms.state.get(rid));\n};","tryCatchPattern":"try {\n  const room = await getRoom();\n} catch (e) {\n  if (e instanceof Error && e.message === 'Room not found') {\n    await refreshRoomStore();\n    return;\n  }\n  throw e;\n}","preventionTips":["Prefer findRoom() for code that can handle a missing room gracefully.","Wait for the initial rooms/subscriptions sync before accessing room data.","Handle the undefined case in UI with a loading or error state."],"tags":["cache","room-data","client-store","data-hydration"],"backgroundTag":null,"analyzedSha":"f9d3ec372bb580fa8d036f94cf03925a478ef768","analyzedAt":"2026-08-12T19:07:17.372Z","schemaVersion":2},"datasetVersion":"2026-08-12T23:17:12.415Z"}