Skip to content

The open alternative to Salesforce, designed for AI.

Skip delayed workflow resume when the run no longer exists (#25528)

Thomas Trompettebbe69331dad6
diff --git a/packages/twenty-server/src/modules/workflow/workflow-executor/workflow-actions/delay/jobs/resume-delayed-workflow.job.ts b/packages/twenty-server/src/modules/workflow/workflow-executor/workflow-actions/delay/jobs/resume-delayed-workflow.job.ts
index 17bc43f9001..d7b8aeed68b 100644
--- a/packages/twenty-server/src/modules/workflow/workflow-executor/workflow-actions/delay/jobs/resume-delayed-workflow.job.ts
+++ b/packages/twenty-server/src/modules/workflow/workflow-executor/workflow-actions/delay/jobs/resume-delayed-workflow.job.ts
@@ -1,5 +1,6 @@
import { Scope } from '@nestjs/common';
+import { isDefined } from 'twenty-shared/utils';
import { StepStatus } from 'twenty-shared/workflow';
import { InjectMessageQueue } from 'src/engine/core-modules/message-queue/decorators/message-queue.decorator';
@@ -43,17 +44,22 @@ export class ResumeDelayedWorkflowJob {
const authContext = buildSystemAuthContext(workspaceId);
await this.workspaceOrmManager.executeInWorkspaceContext(async () => {
- try {
- const workflowRun =
- await this.workflowRunWorkspaceService.getWorkflowRunOrFail({
- workflowRunId,
- workspaceId,
- });
+ const workflowRun = await this.workflowRunWorkspaceService.getWorkflowRun(
+ {
+ workflowRunId,
+ workspaceId,
+ },
+ );
- if (workflowRun.status !== WorkflowRunStatus.RUNNING) {
- return;
- }
+ if (!isDefined(workflowRun)) {
+ return;
+ }
+ if (workflowRun.status !== WorkflowRunStatus.RUNNING) {
+ return;
+ }
+
+ try {
const step = workflowRun.state?.flow?.steps?.find(
(step) => step.id === stepId,
);