refactor(Code Tool Node): Replace vm2 with taskrunner for js (#19247)

This commit is contained in:
yehorkardash
2025-09-09 11:15:31 +00:00
committed by GitHub
parent 04889864a0
commit a910604822
9 changed files with 182 additions and 39 deletions

View File

@@ -21,6 +21,8 @@ import type {
ISourceData,
AiEvent,
NodeConnectionType,
Result,
IExecuteFunctions,
} from 'n8n-workflow';
import {
ApplicationError,
@@ -28,6 +30,7 @@ import {
NodeConnectionTypes,
WAIT_INDEFINITELY,
WorkflowDataProxy,
createEnvProviderState,
} from 'n8n-workflow';
import { BinaryDataService } from '@/binary-data/binary-data.service';
@@ -229,4 +232,29 @@ export class BaseExecuteContext extends NodeExecutionContext {
msg,
});
}
async startJob<T = unknown, E = unknown>(
jobType: string,
settings: unknown,
itemIndex: number,
): Promise<Result<T, E>> {
return await this.additionalData.startRunnerTask<T, E>(
this.additionalData,
jobType,
settings,
this as IExecuteFunctions,
this.inputData,
this.node,
this.workflow,
this.runExecutionData,
this.runIndex,
itemIndex,
this.node.name,
this.connectionInputData,
{},
this.mode,
createEnvProviderState(),
this.executeData,
);
}
}

View File

@@ -14,7 +14,6 @@ import type {
ITaskDataConnections,
IWorkflowExecuteAdditionalData,
NodeExecutionHint,
Result,
StructuredChunk,
Workflow,
WorkflowExecuteMode,
@@ -22,7 +21,6 @@ import type {
import {
ApplicationError,
createDeferredPromise,
createEnvProviderState,
jsonParse,
NodeConnectionTypes,
} from 'n8n-workflow';
@@ -173,31 +171,6 @@ export class ExecuteContext extends BaseExecuteContext implements IExecuteFuncti
await this.additionalData.hooks?.runHook('sendChunk', [message]);
}
async startJob<T = unknown, E = unknown>(
jobType: string,
settings: unknown,
itemIndex: number,
): Promise<Result<T, E>> {
return await this.additionalData.startRunnerTask<T, E>(
this.additionalData,
jobType,
settings,
this,
this.inputData,
this.node,
this.workflow,
this.runExecutionData,
this.runIndex,
itemIndex,
this.node.name,
this.connectionInputData,
{},
this.mode,
createEnvProviderState(),
this.executeData,
);
}
async getInputConnectionData(
connectionType: AINodeConnectionType,
itemIndex: number,