Skip to content

The open alternative to Salesforce, designed for AI.

Give each Sentry cron monitor its own max runtime (#25801)

Etienne9a28e5648363
diff --git a/packages/twenty-server/src/engine/core-modules/cron/sentry-cron-monitor.decorator.ts b/packages/twenty-server/src/engine/core-modules/cron/sentry-cron-monitor.decorator.ts
index e8d45ecb327..465b809dc16 100644
--- a/packages/twenty-server/src/engine/core-modules/cron/sentry-cron-monitor.decorator.ts
+++ b/packages/twenty-server/src/engine/core-modules/cron/sentry-cron-monitor.decorator.ts
@@ -1,6 +1,14 @@
import * as Sentry from '@sentry/node';
-export function SentryCronMonitor(monitorSlug: string, schedule: string) {
+const DEFAULT_MAX_RUNTIME_IN_MINUTES = 5;
+
+export function SentryCronMonitor(
+ monitorSlug: string,
+ schedule: string,
+ {
+ maxRuntimeInMinutes = DEFAULT_MAX_RUNTIME_IN_MINUTES,
+ }: { maxRuntimeInMinutes?: number } = {},
+) {
return function (
// oxlint-disable-next-line typescript/no-explicit-any
_target: any,
@@ -29,7 +37,7 @@ export function SentryCronMonitor(monitorSlug: string, schedule: string) {
value: schedule,
},
checkinMargin: 1,
- maxRuntime: 5,
+ maxRuntime: maxRuntimeInMinutes,
timezone: 'UTC',
},
);
diff --git a/packages/twenty-server/src/engine/workspace-manager/workspace-cleaner/crons/clean-suspended-workspaces.job.ts b/packages/twenty-server/src/engine/workspace-manager/workspace-cleaner/crons/clean-suspended-workspaces.job.ts
index 1fadeb5595a..1130e2928a0 100644
--- a/packages/twenty-server/src/engine/workspace-manager/workspace-cleaner/crons/clean-suspended-workspaces.job.ts
+++ b/packages/twenty-server/src/engine/workspace-manager/workspace-cleaner/crons/clean-suspended-workspaces.job.ts
@@ -35,6 +35,7 @@ export class CleanSuspendedWorkspacesJob {
@SentryCronMonitor(
CleanSuspendedWorkspacesJob.name,
cleanSuspendedWorkspaceCronPattern,
+ { maxRuntimeInMinutes: 15 },
)
async handle(): Promise<void> {
const advisoryLockResult =