Merge pull request #27436 from acierto/master

Cleaning up event subscriptions after the max age window
This commit is contained in:
Patrik Oldsberg
2024-11-02 14:57:54 +01:00
committed by GitHub
2 changed files with 8 additions and 1 deletions
+5
View File
@@ -0,0 +1,5 @@
---
'@backstage/plugin-events-backend': patch
---
Cleaning up event subscriptions after the max age window
@@ -602,7 +602,9 @@ export class DatabaseEventBusStore implements EventBusStore {
if (minId === null) {
// No events left, remove all subscribers. This can happen if no events
// are published within the max age window.
subscriberCount = await this.#db(TABLE_SUBSCRIPTIONS).delete();
subscriberCount = await this.#db(TABLE_SUBSCRIPTIONS)
.where('updated_at', '<', new Date(Date.now() - this.#windowMaxAge))
.delete();
} else {
subscriberCount = await this.#db(TABLE_SUBSCRIPTIONS)
.delete()