Skip to content

Commit 50f4140

Browse files
committed
fix(backend:schedulers): resolve scheduled methods being skipped because of @timeout decorator overlap
1 parent f8bcdf7 commit 50f4140

File tree

2 files changed

+24
-4
lines changed

2 files changed

+24
-4
lines changed

backend/src/applications/files/services/files-scheduler.service.ts

Lines changed: 19 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -36,7 +36,25 @@ export class FilesScheduler {
3636
private readonly filesContentManager: FilesContentManager
3737
) {}
3838

39-
@Timeout(30000)
39+
@Timeout(30_000)
40+
async onStartup(): Promise<void> {
41+
try {
42+
await this.cleanupInterruptedTasks()
43+
await this.clearRecentFiles()
44+
} catch (e) {
45+
this.logger.error(e)
46+
}
47+
}
48+
49+
@Timeout(180_000)
50+
async afterStartup(): Promise<void> {
51+
try {
52+
await this.indexContentFiles()
53+
} catch (e) {
54+
this.logger.error(e)
55+
}
56+
}
57+
4058
async cleanupInterruptedTasks(): Promise<void> {
4159
this.logger.log(`${this.cleanupInterruptedTasks.name} - START`)
4260
try {
@@ -93,7 +111,6 @@ export class FilesScheduler {
93111
this.logger.log(`${this.cleanupUserTaskFiles.name} - END`)
94112
}
95113

96-
@Timeout(30000)
97114
@Cron(CronExpression.EVERY_8_HOURS)
98115
async clearRecentFiles(): Promise<void> {
99116
this.logger.log(`${this.clearRecentFiles.name} - START`)
@@ -120,7 +137,6 @@ export class FilesScheduler {
120137
this.logger.log(`${this.clearRecentFiles.name} - ${nbCleared} records cleared - END`)
121138
}
122139

123-
@Timeout(120000)
124140
@Cron(CronExpression.EVERY_4_HOURS)
125141
async indexContentFiles(): Promise<void> {
126142
// Conditional loading of file content indexing

backend/src/applications/spaces/services/spaces-scheduler.service.ts

Lines changed: 5 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -18,7 +18,11 @@ export class SpacesScheduler {
1818
private readonly sharesManager: SharesManager
1919
) {}
2020

21-
@Timeout(60000)
21+
@Timeout(60_000)
22+
async onStartup() {
23+
await this.updateQuotas()
24+
}
25+
2226
@Cron(CronExpression.EVERY_HOUR)
2327
async updateQuotas() {
2428
this.logger.log('Update Personal Quotas - START')

0 commit comments

Comments
 (0)