fix timer leak in SkRateLimiterService
This commit is contained in:
parent
f6e1b40fd8
commit
0f2e809229
2 changed files with 6 additions and 0 deletions
|
|
@ -13,6 +13,7 @@ import { RoleService } from '@/core/RoleService.js';
|
|||
import { CacheManagementService, type ManagedMemoryKVCache } from '@/global/CacheManagementService.js';
|
||||
import { ConflictError } from '@/misc/errors/ConflictError.js';
|
||||
import { DI } from '@/di-symbols.js';
|
||||
import { bindThis } from '@/decorators.js';
|
||||
|
||||
// Sentinel value used for caching the default role template.
|
||||
// Required because MemoryKVCache doesn't support null keys.
|
||||
|
|
@ -64,6 +65,7 @@ export class SkRateLimiterService {
|
|||
* @param limit The limit definition
|
||||
* @param actorOrUser authenticated client user or IP hash
|
||||
*/
|
||||
@bindThis
|
||||
public async limit(limit: Keyed<RateLimit>, actorOrUser: string | MiUser): Promise<LimitInfo> {
|
||||
if (this.disabled) {
|
||||
return disabledLimitInfo;
|
||||
|
|
|
|||
|
|
@ -67,6 +67,10 @@ describe(SkRateLimiterService, () => {
|
|||
mockEnvService.env.NODE_ENV = 'production';
|
||||
});
|
||||
|
||||
afterEach(() => {
|
||||
serviceUnderTest().dispose();
|
||||
});
|
||||
|
||||
describe('limit', () => {
|
||||
const actor = 'actor';
|
||||
const key = 'test';
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue