From d407726da428af18550a9ee7bc72404e4f75d4f1 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?=E0=A4=95=E0=A4=BE=E0=A4=B0=E0=A4=A4=E0=A5=8B=E0=A4=AB?= =?UTF-8?q?=E0=A5=8D=E0=A4=AB=E0=A5=87=E0=A4=B2=E0=A4=B8=E0=A5=8D=E0=A4=95?= =?UTF-8?q?=E0=A5=8D=E0=A4=B0=E0=A4=BF=E0=A4=AA=E0=A5=8D=E0=A4=9F=E2=84=A2?= Date: Mon, 2 Dec 2024 14:28:33 +0100 Subject: [PATCH] address PR comments --- packages/cli/src/wait-tracker.ts | 1 + packages/cli/src/webhooks/webhook-helpers.ts | 9 +++++---- .../src/node-execution-context/base-execute-context.ts | 4 ++-- 3 files changed, 8 insertions(+), 6 deletions(-) diff --git a/packages/cli/src/wait-tracker.ts b/packages/cli/src/wait-tracker.ts index 2cb67d2027..a80ae8f259 100644 --- a/packages/cli/src/wait-tracker.ts +++ b/packages/cli/src/wait-tracker.ts @@ -138,6 +138,7 @@ export class WaitTracker { const { parentExecution } = fullExecutionData.data; if (parentExecution) { + // on child execution completion, resume parent execution void this.activeExecutions.getPostExecutePromise(executionId).then(() => { void this.startExecution(parentExecution.executionId); }); diff --git a/packages/cli/src/webhooks/webhook-helpers.ts b/packages/cli/src/webhooks/webhook-helpers.ts index 7985cbeab1..c3fbc5c018 100644 --- a/packages/cli/src/webhooks/webhook-helpers.ts +++ b/packages/cli/src/webhooks/webhook-helpers.ts @@ -48,7 +48,7 @@ import type { Project } from '@/databases/entities/project'; import { InternalServerError } from '@/errors/response-errors/internal-server.error'; import { NotFoundError } from '@/errors/response-errors/not-found.error'; import { UnprocessableRequestError } from '@/errors/response-errors/unprocessable.error'; -import type { IExecutionDb, IWorkflowDb } from '@/interfaces'; +import type { IWorkflowDb } from '@/interfaces'; import { Logger } from '@/logging/logger.service'; import { parseBody } from '@/middlewares'; import { OwnershipService } from '@/services/ownership.service'; @@ -549,13 +549,14 @@ export async function executeWebhook( { executionId }, ); + const activeExecutions = Container.get(ActiveExecutions); + // Get a promise which resolves when the workflow did execute and send then response - const executePromise = Container.get(ActiveExecutions).getPostExecutePromise( - executionId, - ) as Promise; + const executePromise = activeExecutions.getPostExecutePromise(executionId); const { parentExecution } = runExecutionData; if (parentExecution) { + // on child execution completion, resume parent execution void executePromise.then(() => { const waitTracker = Container.get(WaitTracker); void waitTracker.startExecution(parentExecution.executionId); diff --git a/packages/core/src/node-execution-context/base-execute-context.ts b/packages/core/src/node-execution-context/base-execute-context.ts index ccda7dc531..39aeedfc19 100644 --- a/packages/core/src/node-execution-context/base-execute-context.ts +++ b/packages/core/src/node-execution-context/base-execute-context.ts @@ -115,14 +115,14 @@ export class BaseExecuteContext extends NodeExecutionContext { ): Promise { const result = await this.additionalData.executeWorkflow(workflowInfo, this.additionalData, { ...options, - parentWorkflowId: this.workflow.id?.toString(), + parentWorkflowId: this.workflow.id, inputData, parentWorkflowSettings: this.workflow.settings, node: this.node, parentCallbackManager, }); - // If a subworkflow goes into the waiting state, then put the parent workflow also into the waiting state + // If a sub-workflow execution goes into the waiting state, then put the parent workflow execution also into the waiting state if (result.waitTill) { await this.putExecutionToWait(result.waitTill); }