RocketChat/Rocket.Chat · error · Meteor.Error
error-invalid-user
error-invalid-user
Error message
Invalid user
What it means
Authentication gate of the channelsList Meteor method (deprecated in 9.0.0 in favor of GET /v1/channels.list): Meteor.userId() was null when the method executed. Even though the method only lists channels, it requires a logged-in user because its results are permission-filtered (e.g. view-p-room for the private-channel branch).
Source
Thrown at apps/meteor/server/meteor-methods/rooms/channelsList.ts:33
declare module '@rocket.chat/ddp-client' {
// eslint-disable-next-line @typescript-eslint/naming-convention
interface ServerMethods {
channelsList(filter: string, channelType: string, limit?: number, sort?: string): { channels: IRoom[] };
}
}
Meteor.methods<ServerMethods>({
async channelsList(filter, channelType, limit, sort) {
methodDeprecationLogger.method('channelsList', '9.0.0', '/v1/channels.list');
check(filter, String);
check(channelType, String);
check(limit, Match.Optional(Number));
check(sort, Match.Optional(String));
const userId = Meteor.userId();
if (!userId) {
throw new Meteor.Error('error-invalid-user', 'Invalid user', {
method: 'channelsList',
});
}
const options: FindOptions<IRoom> = {
projection: {
name: 1,
t: 1,
},
sort: {
msgs: -1,
},
};
if (_.isNumber(limit)) {
options.limit = limit;
}
View on GitHub (pinned to b2c16d5842)
Solutions
- Await a successful login before calling channelsList (react on Meteor.userId() becoming non-null).
- Re-authenticate if the session was invalidated, then retry.
- Use GET /api/v1/channels.list with token auth for server-side integrations.
Example fix
// before
Meteor.call('channelsList', filter, channelType);
// after
if (Meteor.userId()) {
Meteor.call('channelsList', filter, channelType);
} else {
await relogin();
Meteor.call('channelsList', filter, channelType);
} Defensive patterns
Strategy: validation
Validate before calling
if (!Meteor.userId()) {
// channelsList requires a logged-in user - redirect to login instead of calling
} Try / catch
try {
const result = await Meteor.callAsync('channelsList', filter, channelType, limit, sort);
} catch (e) {
if (e instanceof Meteor.Error && e.error === 'error-invalid-user') {
// session gone: re-login, then retry the listing once
await relogin();
return Meteor.callAsync('channelsList', filter, channelType, limit, sort);
}
throw e;
} Prevention
- Do not call channelsList during boot before the login state resolves.
- Cache listing data across brief reconnects instead of calling with an anonymous connection.
- Prefer GET /api/v1/channels.list for server-side integrations.
When it happens
Trigger: Calling Meteor.call('channelsList', filter, channelType, limit, sort) before the client's login completed; invoking after the login token expired or was invalidated; a DDP script that connects but never logs in.
Common situations: Directory/search UI loading during boot racing the Accounts login; sessions invalidated by password change or server restart; automated clients forgetting the login step.
Related errors
AI-assisted analysis of RocketChat/Rocket.Chat@b2c16d5842 (2026-08-18).
Data as JSON: /api/errors/e2866b82a646af0a.
Report an issue: GitHub.