mirror of
https://github.com/Abdulazizzn/n8n-enterprise-unlocked.git
synced 2025-12-17 10:02:05 +00:00
refactor(core): Include native Python option in Code node (#18331)
This commit is contained in:
@@ -1,13 +1,12 @@
|
||||
import {
|
||||
ApplicationError,
|
||||
type CodeExecutionMode,
|
||||
type IExecuteFunctions,
|
||||
type INodeExecutionData,
|
||||
type WorkflowExecuteMode,
|
||||
} from 'n8n-workflow';
|
||||
|
||||
import { isWrappableError, WrappedExecutionError } from './errors/WrappedExecutionError';
|
||||
import { validateNoDisallowedMethodsInRunForEach } from './JsCodeValidator';
|
||||
import { throwExecutionError } from './throw-execution-error';
|
||||
|
||||
/**
|
||||
* JS Code execution sandbox that executes the JS code using task runner.
|
||||
@@ -37,7 +36,7 @@ export class JsTaskRunnerSandbox {
|
||||
|
||||
return executionResult.ok
|
||||
? executionResult.result
|
||||
: this.throwExecutionError('error' in executionResult ? executionResult.error : {});
|
||||
: throwExecutionError('error' in executionResult ? executionResult.error : {});
|
||||
}
|
||||
|
||||
async runCodeForEachItem(numInputItems: number): Promise<INodeExecutionData[]> {
|
||||
@@ -64,7 +63,7 @@ export class JsTaskRunnerSandbox {
|
||||
);
|
||||
|
||||
if (!executionResult.ok) {
|
||||
return this.throwExecutionError('error' in executionResult ? executionResult.error : {});
|
||||
return throwExecutionError('error' in executionResult ? executionResult.error : {});
|
||||
}
|
||||
|
||||
executionResults = executionResults.concat(executionResult.result);
|
||||
@@ -73,18 +72,6 @@ export class JsTaskRunnerSandbox {
|
||||
return executionResults;
|
||||
}
|
||||
|
||||
private throwExecutionError(error: unknown): never {
|
||||
if (error instanceof Error) {
|
||||
throw error;
|
||||
} else if (isWrappableError(error)) {
|
||||
// The error coming from task runner is not an instance of error,
|
||||
// so we need to wrap it in an error instance.
|
||||
throw new WrappedExecutionError(error);
|
||||
}
|
||||
|
||||
throw new ApplicationError(`Unknown error: ${JSON.stringify(error)}`);
|
||||
}
|
||||
|
||||
/** Chunks the input items into chunks of 1000 items each */
|
||||
private chunkInputItems(numInputItems: number) {
|
||||
const numChunks = Math.ceil(numInputItems / this.chunkSize);
|
||||
|
||||
Reference in New Issue
Block a user