RocketChat/Rocket.Chat · warning · Error
Subscription not found
Error message
Subscription not found
What it means
getSubscription is produced by createStrictGetter(findSubscription, 'Subscription not found'): it throws when Subscriptions.state.find finds no record with rid matching the chat context. A missing subscription means the current user is not (or not yet) a member of the room in the client's synced state.
Solutions
- Check isSubscribedToRoom() first and branch (join prompt vs member UI).
- Use the underlying findSubscription and handle undefined.
- Ensure the subscriptions store is loaded before rendering member-only affordances.
Example fix
// before
const sub = await chat.getSubscription();
// after
if (!(await chat.isSubscribedToRoom())) {
// not a member: preview UI or joinRoom() first
return;
}
const sub = await chat.getSubscription(); Defensive patterns
Strategy: validation
Validate before calling
if (!(await chat.isSubscribedToRoom())) {
// previewing without membership — join first or render preview UI
return;
}
const sub = await chat.getSubscription(); Prevention
- Branch UI on isSubscribedToRoom() before touching subscriptions.
- Remember public-channel previews have rooms but no subscription records.
- Re-check membership after join/leave transitions update the store.
When it happens
Trigger: Calling getSubscription while previewing a public channel the user has not joined, before subscriptions finish syncing after login, after being removed from the room while its UI is still open, or for a logged-out/anonymized state.
Common situations: Public channel preview flows, notification deep-links into unjoined rooms, team channels the user was kicked from mid-session, race at app startup.
Related errors
- Room not found
- Discussion not found
- error-invalid-room
- error-invalid-subscription
- error-invalid-subscription
AI-assisted analysis of RocketChat/Rocket.Chat@2f18297792 (2026-08-18).
Data as JSON: /api/errors/b7d5fd768387d855.
Report an issue: GitHub.
Appendix: source
Thrown at apps/meteor/client/lib/chats/data.ts:301
const getDiscussionByID = async (drid: IRoom['_id']): Promise<IRoom> => {
const discussion = await findDiscussionByID(drid);
if (!discussion) {
throw new Error('Discussion not found');
}
return discussion;
};
const createStrictGetter = <TFind extends (...args: any[]) => Promise<any>>(
find: TFind,
errorMessage: string,
): ((...args: Parameters<TFind>) => Promise<Exclude<Awaited<ReturnType<TFind>>, undefined>>) => {
return async (...args) => {
const result = await find(...args);
if (!result) {
throw new Error(errorMessage);
}
return result;
};
};
const findSubscription = async (): Promise<ISubscription | undefined> => {
return Subscriptions.state.find((record) => record.rid === rid);
};
const getSubscription = createStrictGetter(findSubscription, 'Subscription not found');
const findSubscriptionFromMessage = async (message: IMessage): Promise<ISubscription | undefined> => {
return Subscriptions.state.find((record) => record.rid === message.rid);
};
const getSubscriptionFromMessage = createStrictGetter(findSubscriptionFromMessage, 'Subscription not found');
View on GitHub (pinned to 2f18297792)