Cleanup intervals on destroyed views extension

This commit is contained in:
Tom Moor
2023-06-25 22:52:28 -04:00
parent 94882d4d3a
commit edb9099c9d
3 changed files with 14 additions and 2 deletions

View File

@@ -70,4 +70,15 @@ export class ViewsExtension implements Extension {
this.intervalsBySocket.delete(socketId);
}
}
/**
* onDestroy hook
* @param data The destroy payload
*/
async onDestroy() {
this.intervalsBySocket.forEach((interval, socketId) => {
clearInterval(interval);
this.intervalsBySocket.delete(socketId);
});
}
}

View File

@@ -541,8 +541,8 @@ export class Environment {
this.toOptionalNumber(process.env.RATE_LIMITER_REQUESTS) ?? 1000;
/**
* Set max allowed realtime connections in a minute before throttling. Defaults
* to 50 requests/ip/min.
* Set max allowed realtime connections before throttling. Defaults to 50
* requests/ip/duration window.
*/
@IsOptional()
@IsNumber()

View File

@@ -34,6 +34,7 @@ export default function init(
extensions: [
new Throttle({
throttle: env.RATE_LIMITER_COLLABORATION_REQUESTS,
consideredSeconds: env.RATE_LIMITER_DURATION_WINDOW,
// Ban time is defined in minutes
banTime: 5,
}),