{"record":{"id":"030c3a6dfde1ad74","repo":"RocketChat/Rocket.Chat","slug":"too-many-requests","errorCode":"too-many-requests","errorMessage":"too-many-requests","messagePattern":"too-many-requests","errorType":"error_code","errorClass":"Meteor.Error","httpStatus":400,"severity":"error","filePath":"apps/meteor/server/api/v1/misc.ts","lineNumber":666,"sourceCode":"\t\t\tthis.token ||\n\t\t\tcrypto\n\t\t\t\t.createHash('sha256')\n\t\t\t\t.update((this.requestIp ?? '') + this.user._id)\n\t\t\t\t.digest('hex');\n\n\t\tconst rateLimiterInput = {\n\t\t\tuserId: this.userId,\n\t\t\tclientAddress: this.requestIp,\n\t\t\ttype: 'method',\n\t\t\tname: method,\n\t\t\tconnectionId,\n\t\t};\n\n\t\ttry {\n\t\t\tDDPRateLimiter._increment(rateLimiterInput);\n\t\t\tconst rateLimitResult = DDPRateLimiter._check(rateLimiterInput);\n\t\t\tif (!rateLimitResult.allowed) {\n\t\t\t\tthrow new Meteor.Error('too-many-requests', DDPRateLimiter.getErrorMessage(rateLimitResult), {\n\t\t\t\t\ttimeToReset: rateLimitResult.timeToReset,\n\t\t\t\t});\n\t\t\t}\n\n\t\t\treturn API.v1.success(mountResult({ id, result: await Meteor.callAsync(method, ...params) }));\n\t\t} catch (err) {\n\t\t\tlogMethodCallError(method, err);\n\n\t\t\treturn API.v1.failure(mountResult({ id, error: err }));\n\t\t}\n\t},\n);\n\nAPI.v1.post(\n\t'method.callAnon/:method',\n\t{\n\t\tauthRequired: false,\n\t\tuserWithoutUsername: true,","sourceCodeStart":648,"sourceCodeEnd":684,"githubUrl":"https://github.com/RocketChat/Rocket.Chat/blob/2a7de457074cbb4d4373fbd9a4e5bea292c9c764/apps/meteor/server/api/v1/misc.ts#L648-L684","documentation":"POST /api/v1/method.call/:method bridges REST to DDP method invocation. Before calling Meteor.callAsync it runs DDPRateLimiter._increment then _check keyed on {userId, clientAddress, type: 'method', name: method, connectionId} (misc.ts:662-669); when a matching rate-limit rule trips, the call aborts with Meteor.Error('too-many-requests') and details.timeToReset (ms until the window frees). Because _increment runs first, every rejected request also consumed quota - immediate retries extend the block. The endpoint's own catch then serializes this error into the DDP-style result envelope (mountResult), so callers see it inside the method-call payload rather than as a standard REST error body.","triggerScenarios":"Repeating the same DDP method (sendMessage, login, typing notifications...) through method.call faster than a configured DDPRateLimiter rule allows; several scripts sharing one user token or one source IP so their requests pool into the same bucket.","commonSituations":"Polling loops that invoke a method per tick; brute-force protections on login methods; office NAT causing clientAddress bucket collisions; connectionId derived from the token hash so one token equals one bucket.","solutions":["Parse the returned EJSON error and read details.timeToReset - wait at least that long (plus margin) before retrying","Throttle or batch the client so it stays under the rule's limit instead of retrying into it","Ask the workspace admin to review the DDPRateLimiter rule for that method name and raise the limit if the traffic is legitimate","Prefer the native REST endpoints over the method.call bridge - they do not pass through the method rate limiter"],"exampleFix":"// before\n while (true) {\n   await api.post('/api/v1/method.call/sendMessage', { message: EJSON.stringify({ method: 'sendMessage', params, id }) });\n }\n\n // after: respect timeToReset\n try {\n   await api.post('/api/v1/method.call/sendMessage', { message: EJSON.stringify({ method: 'sendMessage', params, id }) });\n } catch (err) {\n   if (err.error === 'too-many-requests') {\n     await new Promise((r) => setTimeout(r, (err.details?.timeToReset ?? 1000) + 100));\n   }\n }","handlingStrategy":"retry","validationCode":"if (callsPerSecond(method) > configuredLimit(method)) {\n  await throttle(method, configuredLimit(method)); // client-side limiter mirroring the server rule\n}\nawait api.post(`/api/v1/method.call/${method}`, { message: EJSON.stringify({ method, params, id }) });","typeGuard":null,"tryCatchPattern":"try {\n  return await api.post(`/api/v1/method.call/${method}`, { message: EJSON.stringify({ method, params, id }) });\n} catch (err) {\n  if (err?.error === 'too-many-requests') {\n    const wait = (err.details?.timeToReset ?? 1000) + 100; // ms; each rejected call already consumed quota\n    await new Promise((r) => setTimeout(r, wait));\n    return api.post(`/api/v1/method.call/${method}`, { message: EJSON.stringify({ method, params, id }) }); // retry once\n  }\n  throw err;\n}","preventionTips":["Respect details.timeToReset - retrying early re-increments the counter and extends the block","Prefer native REST endpoints over the method.call bridge where equivalents exist","Run client-side token-bucket limiting matched to the admin's DDPRateLimiter rules; batch bursts instead of spraying"],"tags":["rate-limit","ddp","rest-api","throttling"],"backgroundTag":"rate-limit-exceeded","analyzedSha":"2a7de457074cbb4d4373fbd9a4e5bea292c9c764","analyzedAt":"2026-08-18T15:26:39.429Z","contentChangedAt":"2026-08-18T15:26:39.429Z","schemaVersion":2},"datasetVersion":"2026-09-23T08:17:48.524Z"}