@@ -3,6 +3,7 @@ import { Logger } from '@rocket.chat/logger';
33import { Users } from '@rocket.chat/models' ;
44import { Random } from '@rocket.chat/random' ;
55import type { JoinPathPattern , Method } from '@rocket.chat/rest-typings' ;
6+ import { wrapExceptions } from '@rocket.chat/tools' ;
67import express from 'express' ;
78import type { Request , Response } from 'express' ;
89import { Accounts } from 'meteor/accounts-base' ;
@@ -404,10 +405,14 @@ export class APIClass<TBasePath extends string = ''> {
404405 public reloadRoutesToRefreshRateLimiter ( ) : void {
405406 this . _routes . forEach ( ( route ) => {
406407 if ( this . shouldAddRateLimitToRoute ( route . options ) ) {
407- this . addRateLimiterRuleForRoutes ( {
408- routes : [ route . path ] ,
409- rateLimiterOptions : route . options . rateLimiterOptions || defaultRateLimiterOptions ,
410- endpoints : Object . keys ( route . endpoints ) . filter ( ( endpoint ) => endpoint !== 'options' ) ,
408+ wrapExceptions ( ( ) =>
409+ this . addRateLimiterRuleForRoutes ( {
410+ routes : [ route . path ] ,
411+ rateLimiterOptions : route . options . rateLimiterOptions || defaultRateLimiterOptions ,
412+ endpoints : Object . keys ( route . endpoints ) . filter ( ( endpoint ) => endpoint !== 'options' ) ,
413+ } ) ,
414+ ) . catch ( ( error ) => {
415+ console . error ( error . message ) ;
411416 } ) ;
412417 }
413418 } ) ;
@@ -426,10 +431,10 @@ export class APIClass<TBasePath extends string = ''> {
426431 throw new Meteor . Error ( '"rateLimiterOptions" must be an object' ) ;
427432 }
428433 if ( ! rateLimiterOptions . numRequestsAllowed ) {
429- throw new Meteor . Error ( ' You must set "numRequestsAllowed" property in rateLimiter for REST API endpoint' ) ;
434+ throw new Meteor . Error ( ` You must set "numRequestsAllowed" property in rateLimiter for REST API endpoint: ${ routes } ` ) ;
430435 }
431436 if ( ! rateLimiterOptions . intervalTimeInMS ) {
432- throw new Meteor . Error ( ' You must set "intervalTimeInMS" property in rateLimiter for REST API endpoint' ) ;
437+ throw new Meteor . Error ( ` You must set "intervalTimeInMS" property in rateLimiter for REST API endpoint: ${ routes } ` ) ;
433438 }
434439 const addRateLimitRuleToEveryRoute = ( routes : string [ ] ) => {
435440 routes . forEach ( ( route ) => {
0 commit comments