{"record":{"id":"245edda610859b39","repo":"RocketChat/Rocket.Chat","slug":"error-user-limit-exceeded","errorCode":"error-user-limit-exceeded","errorMessage":"User Limit Exceeded","messagePattern":"User Limit Exceeded","errorType":"exception","errorClass":"Meteor.Error","httpStatus":null,"severity":"error","filePath":"apps/meteor/server/meteor-methods/rooms/addAllUserToRoom.ts","lineNumber":43,"sourceCode":"\tcheck(rid, String);\n\tcheck(activeUsersOnly, Boolean);\n\n\tif (!(await hasPermissionAsync(userId, 'add-all-to-room'))) {\n\t\tthrow new Meteor.Error(403, 'Access to Method Forbidden', {\n\t\t\tmethod: 'addAllToRoom',\n\t\t});\n\t}\n\n\tconst userFilter: {\n\t\tactive?: boolean;\n\t} = {};\n\tif (activeUsersOnly === true) {\n\t\tuserFilter.active = true;\n\t}\n\n\tconst users = await Users.find(userFilter).toArray();\n\tif (users.length > settings.get<number>('API_User_Limit')) {\n\t\tthrow new Meteor.Error('error-user-limit-exceeded', 'User Limit Exceeded', {\n\t\t\tmethod: 'addAllToRoom',\n\t\t});\n\t}\n\n\tconst room = await Rooms.findOneById(rid);\n\tif (!room) {\n\t\tthrow new Meteor.Error('error-invalid-room', 'Invalid room', {\n\t\t\tmethod: 'addAllToRoom',\n\t\t});\n\t}\n\n\tawait beforeAddUserToRoom(\n\t\tusers.map((u) => u.username!),\n\t\troom,\n\t);\n\n\tconst now = new Date();\n\tfor await (const user of users) {","sourceCodeStart":25,"sourceCodeEnd":61,"githubUrl":"https://github.com/RocketChat/Rocket.Chat/blob/b2c16d5842cbe6b69b59bdf6fc5e5f1afcd1f0b0/apps/meteor/server/meteor-methods/rooms/addAllUserToRoom.ts#L25-L61","documentation":"Before adding anyone, addAllUserToRoomFn loads all users (only active ones when activeUsersOnly=true) and compares the count to the API_User_Limit setting. If the workspace has more users than that setting allows, it throws error-user-limit-exceeded - a safety valve against an unbounded storm of subscription writes and 'uj' system messages that could stall a large server.","triggerScenarios":"Calling addAllUserToRoom (or channels.addAll/groups.addAll) on a server whose total user count exceeds API_User_Limit; passing activeUsersOnly=false counts deactivated users too, making the limit easier to hit.","commonSituations":"Growing communities where API_User_Limit was left at a low default; operators forgetting activeUsersOnly=true; imported user bases that inflate the count.","solutions":["Raise the API_User_Limit setting above the workspace user count, sizing for the resulting N subscription writes and system messages.","Pass activeUsersOnly=true so only active users are counted and added.","On very large servers, add specific users instead (channels.invite / addUserToRoom)."],"exampleFix":"// before\nawait Meteor.callAsync('addAllUserToRoom', rid, false);\n\n// after\n// only bulk-add when the active population fits the configured limit\nawait Meteor.callAsync('addAllUserToRoom', rid, true);","handlingStrategy":"validation","validationCode":"// preflight: compare workspace user count against the limit before bulk-adding\nconst stats = await fetch('/api/v1/statistics', { headers }).then((r) => r.json());\nconst totalUsers = stats.statistics?.totalUsers ?? 0;\nif (totalUsers > Number(apiUserLimit)) {\n\tthrow new Error('Workspace exceeds API_User_Limit - raise the setting or add users individually');\n}","typeGuard":null,"tryCatchPattern":"try {\n\tawait Meteor.callAsync('addAllUserToRoom', rid, true);\n} catch (e: any) {\n\tif (e?.error === 'error-user-limit-exceeded') {\n\t\t// ask the operator to raise API_User_Limit or use targeted invites\n\t}\n}","preventionTips":["Keep API_User_Limit aligned with actual workspace size when bulk adds are expected.","Default to activeUsersOnly=true so deactivated accounts do not count.","For large servers, prefer targeted invites over bulk add."],"tags":["meteor-methods","rooms","limits","settings"],"backgroundTag":"user-limit-exceeded","analyzedSha":"b2c16d5842cbe6b69b59bdf6fc5e5f1afcd1f0b0","analyzedAt":"2026-08-18T15:26:39.429Z","schemaVersion":2},"datasetVersion":"2026-08-21T13:17:26.733Z"}