RocketChat/Rocket.Chat · warning · NotSubscribedToRoomError

not-subscribed-room

not-subscribed-room

Error message

Not subscribed to this room

What it means

NotSubscribedToRoomError (`not-subscribed-room`) thrown by useOpenRoom when the room was resolved, the user is logged in, has no subscription record for it, has no preview permission, and the room is public. It is control flow: react-query consumers catch it to render the room preview screen instead of opening the room.

Solutions

  1. Join the room (POST /v1/channels.join or /v1/groups.join) before opening it.
  2. Grant the user a role with the preview-public-room permission if previewing is intended.
  3. In UI code, catch this error specifically and navigate to the preview route rather than showing a generic error.

Example fix

// before
try {
	await openRoom(type, reference);
} catch (e) {
	showError(e); // generic toast for a control-flow error
}

// after
try {
	await openRoom(type, reference);
} catch (e) {
	if (e instanceof NotSubscribedToRoomError) {
		previewRoute.push({ rid: e.details?.rid });
		return;
	}
	throw e;
}
Defensive patterns

Strategy: try-catch

Validate before calling

const isSubscribed = (type: string, reference: string): boolean =>
	Boolean(Subscriptions.state.find((record) => record.t === type && (record.rid === reference || record.name === reference)));

Type guard

const isNotSubscribedToRoomError = (error: unknown): error is NotSubscribedToRoomError =>
	Boolean(error && typeof error === 'object' && 'error' in error && (error as { error: string }).error === 'not-subscribed-room');

Try / catch

try {
	const { rid } = await openRoom(type, reference);
} catch (error) {
	if (isNotSubscribedToRoomError(error)) {
		// control flow: render the public-room preview screen
		previewRoute.push({ rid: error.details?.rid ?? '' });
		return;
	}
	throw error;
}

Prevention

When it happens

Trigger: Logged-in user without membership opening a public channel URL while lacking preview permissions (e.g. uninvited users can't preview); subscription not yet synced to the client after joining elsewhere.

Common situations: Clicking a shared public-channel link as a non-member on workspaces that disable previews for users without the preview room permission; race right after join-room where the subscription hasn't propagated.

Related errors


AI-assisted analysis of RocketChat/Rocket.Chat@2f18297792 (2026-08-18). Data as JSON: /api/errors/cbabe2f58eb7eb82. Report an issue: GitHub.

Appendix: source

Thrown at apps/meteor/client/views/room/hooks/useOpenRoom.ts:135

			const room = Rooms.state.get(roomData._id);

			if (!room) {
				throw new TypeError('room is undefined');
			}

			const sub = Subscriptions.state.find((record) => record.t === type && (record.rid === reference || record.name === reference));

			if (reference !== undefined && room._id !== reference && type === 'd') {
				// Redirect old url using username to rid
				LegacyRoomManager.close(type + reference);
				directRoute.push({ rid: room._id }, (prev) => prev);
				throw new OldUrlRoomError(undefined, { rid: room._id });
			}

			// if user doesn't exist at this point, anonymous read is enabled, otherwise an error would have been thrown
			if (user && !sub && !hasPreviewPermission && isPublicRoom(room)) {
				throw new NotSubscribedToRoomError(undefined, { rid: room._id });
			}

			LegacyRoomManager.open({ typeName: type + reference, rid: room._id });

			if (room._id === RoomManager.opened) {
				return { rid: room._id };
			}

			// update user's room subscription

			if (!!user?._id && sub && !sub.open) {
				await openRoom.mutateAsync({ roomId: room._id, userId: user._id });
			}

			return { rid: room._id };
		},
		retry: (failureCount, error) => {
			const unrecoverableErrors = [RoomNotFoundError, OldUrlRoomError, NotAuthorizedError, NotSubscribedToRoomError];

View on GitHub (pinned to 2f18297792)