RocketChat/Rocket.Chat · error · Meteor.Error
error-invalid-user
error-invalid-user
Error message
Invalid user
What it means
getImportProgress requires a logged-in DDP user; when `Meteor.userId()` is null it throws error-invalid-user. It is the authentication gate before the run-import permission check, identical in shape to the guard in getImportFileData.
Source
Thrown at apps/meteor/server/meteor-methods/import/getImportProgress.ts:39
const instance = new importer.importer(importer, operation); // eslint-disable-line new-cap
return instance.getProgress();
};
declare module '@rocket.chat/ddp-client' {
// eslint-disable-next-line @typescript-eslint/naming-convention
interface ServerMethods {
getImportProgress(): IImportProgress;
}
}
Meteor.methods<ServerMethods>({
async getImportProgress() {
methodDeprecationLogger.method('getImportProgress', '9.0.0', '/v1/getImportProgress');
const userId = Meteor.userId();
if (!userId) {
throw new Meteor.Error('error-invalid-user', 'Invalid user', 'getImportProgress');
}
if (!(await hasPermissionAsync(userId, 'run-import'))) {
throw new Meteor.Error('error-action-not-allowed', 'Importing is not allowed', 'setupImporter');
}
return executeGetImportProgress();
},
});
View on GitHub (pinned to b2c16d5842)
Solutions
- Ensure an authenticated session before polling (`Meteor.userId()` is set)
- Re-authenticate on this error and resume polling
- Move automation to POST /v1/getImportProgress with X-User-Id/X-Auth-Token headers
Example fix
// before
setInterval(() => Meteor.call('getImportProgress', cb), 2000); // error-invalid-user after logout
// after
setInterval(() => {
if (!Meteor.userId()) { stopPolling(); return; }
Meteor.call('getImportProgress', cb);
}, 2000); Defensive patterns
Strategy: validation
Validate before calling
if (!Meteor.userId()) { await relogin(); }
Meteor.call('getImportProgress', cb); Try / catch
Meteor.call('getImportProgress', (err, p) => {
if (err && (err as Meteor.Error).error === 'error-invalid-user') {
stopPolling(); // then re-login and restart the poll
}
}); Prevention
- Stop progress polling on logout/session-expiry events
- Re-authenticate before long import sessions
- Use REST /v1/getImportProgress for headless monitoring
When it happens
Trigger: Polling `Meteor.call('getImportProgress')` from a connection whose session expired or that never logged in; calling the method from a background job without user context.
Common situations: Progress-polling loops that outlive the login session (long imports); scripts hitting DDP directly; front-end code that starts polling after logout.
Related errors
AI-assisted analysis of RocketChat/Rocket.Chat@b2c16d5842 (2026-08-18).
Data as JSON: /api/errors/bfb2910b617218b6.
Report an issue: GitHub.