RocketChat/Rocket.Chat · warning · Meteor.Error
error-no-tokens-for-this-user
error-no-tokens-for-this-user
Error message
There are no tokens for this user
What it means
executePushTest (behind the push_test method, deprecated in favor of /v1/push/test) counts the user's registered push tokens via PushToken.countTokensByUserId; with zero tokens there is no device to deliver a test to, so it throws Meteor.Error('error-no-tokens-for-this-user', ..., { method: 'push_test' }) before sending anything.
Source
Thrown at apps/meteor/server/lib/pushConfig.ts:17
import type { IUser } from '@rocket.chat/core-typings';
import type { ServerMethods } from '@rocket.chat/ddp-client';
import { PushToken } from '@rocket.chat/models';
import { Meteor } from 'meteor/meteor';
import { RateLimiterClass as RateLimiter } from './RateLimiter';
import { hasPermissionAsync } from './authorization/hasPermission';
import { methodDeprecationLogger } from './deprecationWarningLogger';
import { i18n } from './i18n';
import { settings } from '../settings';
import { Push } from './notifications/push';
export const executePushTest = async (userId: IUser['_id'], username: IUser['username']): Promise<number> => {
const tokens = await PushToken.countTokensByUserId(userId);
if (tokens === 0) {
throw new Meteor.Error('error-no-tokens-for-this-user', 'There are no tokens for this user', {
method: 'push_test',
});
}
await Push.send({
from: 'push',
title: `@${username}`,
text: i18n.t('This_is_a_push_test_messsage'),
sound: 'default',
userId,
});
return tokens;
};
declare module '@rocket.chat/ddp-client' {
// eslint-disable-next-line @typescript-eslint/naming-convention
interface ServerMethods {View on GitHub (pinned to b2c16d5842)
Solutions
- Log in on a mobile/login client with push enabled as the same user, send any message to trigger registration, then retry push_test
- Verify Admin > Push settings (gateway, Push_enable=true) and that the app registered a token (check the push token collection for the user)
- Keep in mind push_test is deprecated since 9.0 — prefer the /v1/push/test REST endpoint
- If tokens exist but the count is 0 for that user, confirm you're testing with the same userId that owns the device
Defensive patterns
Strategy: validation
Validate before calling
// server-side guard before running the test
import { PushToken } from '@rocket.chat/models';
const tokens = await PushToken.countTokensByUserId(userId);
if (tokens === 0) {
return { skipped: true, reason: 'no registered devices — log in on a push-enabled client first' };
}
await executePushTest(userId, username); Try / catch
try {
await Meteor.callAsync('push_test');
} catch (err) {
if (err instanceof Meteor.Error && err.error === 'error-no-tokens-for-this-user') {
// instruct the user to log in on a push-enabled device, then retry
} else {
throw err;
}
} Prevention
- Register at least one device (mobile/login client) before testing push
- Verify Push gateway settings and Push_enable=true so token registration works
- Prefer the /v1/push/test REST endpoint — push_test is deprecated since 9.0
When it happens
Trigger: Invoking push_test for a user who never registered a device: no mobile/login client logged in with push configured for that account, tokens wiped (db.rocketchat_push_token empty for the user), or push gateway not set up so tokens were never stored.
Common situations: Admins testing push before anyone logged in on the mobile app, testing with a user other than the one holding the device, Push settings (gateway/queue) misconfigured so registration silently failed, or testing right after wiping devices.
Related errors
- error-authToken-param-not-valid
- error-user-not-found
- error-message-not-found
- error-room-not-found
- error-not-allowed
AI-assisted analysis of RocketChat/Rocket.Chat@b2c16d5842 (2026-08-18).
Data as JSON: /api/errors/b5a9aa4fa6bec04f.
Report an issue: GitHub.