mirror of
https://github.com/Abdulazizzn/n8n-enterprise-unlocked.git
synced 2025-12-17 18:12:04 +00:00
feat(cli): Load all nodes and credentials code in isolation - N8N-4362 (#3906)
[N8N-4362] Load all nodes and credentials code in isolation Co-authored-by: Omar Ajoue <krynble@gmail.com>
This commit is contained in:
committed by
GitHub
parent
9267e8fb12
commit
b450e977a3
@@ -49,6 +49,7 @@ import { getLogger } from './Logger';
|
||||
import config from '../config';
|
||||
import { InternalHooksManager } from './InternalHooksManager';
|
||||
import { checkPermissionsForExecution } from './UserManagement/UserManagementHelper';
|
||||
import { loadClassInIsolation } from './CommunityNodes/helpers';
|
||||
|
||||
export class WorkflowRunnerProcess {
|
||||
data: IWorkflowExecutionDataProcessWithExecution | undefined;
|
||||
@@ -92,41 +93,30 @@ export class WorkflowRunnerProcess {
|
||||
workflowId: this.data.workflowData.id,
|
||||
});
|
||||
|
||||
let className: string;
|
||||
let tempNode: INodeType;
|
||||
let tempCredential: ICredentialType;
|
||||
let filePath: string;
|
||||
|
||||
this.startedAt = new Date();
|
||||
|
||||
// Load the required nodes
|
||||
const nodeTypesData: INodeTypeData = {};
|
||||
// eslint-disable-next-line no-restricted-syntax
|
||||
for (const nodeTypeName of Object.keys(this.data.nodeTypeData)) {
|
||||
className = this.data.nodeTypeData[nodeTypeName].className;
|
||||
|
||||
filePath = this.data.nodeTypeData[nodeTypeName].sourcePath;
|
||||
// eslint-disable-next-line @typescript-eslint/no-unsafe-assignment, import/no-dynamic-require, global-require, @typescript-eslint/no-var-requires
|
||||
const tempModule = require(filePath);
|
||||
let tempNode: INodeType;
|
||||
const { className, sourcePath } = this.data.nodeTypeData[nodeTypeName];
|
||||
|
||||
try {
|
||||
// eslint-disable-next-line @typescript-eslint/no-unsafe-call
|
||||
const nodeObject = new tempModule[className]();
|
||||
const nodeObject = loadClassInIsolation(sourcePath, className);
|
||||
if (nodeObject.getNodeType !== undefined) {
|
||||
// eslint-disable-next-line @typescript-eslint/no-unsafe-call
|
||||
tempNode = nodeObject.getNodeType();
|
||||
} else {
|
||||
tempNode = nodeObject;
|
||||
}
|
||||
// eslint-disable-next-line @typescript-eslint/no-unsafe-call
|
||||
tempNode = new tempModule[className]() as INodeType;
|
||||
} catch (error) {
|
||||
throw new Error(`Error loading node "${nodeTypeName}" from: "${filePath}"`);
|
||||
throw new Error(`Error loading node "${nodeTypeName}" from: "${sourcePath}"`);
|
||||
}
|
||||
|
||||
nodeTypesData[nodeTypeName] = {
|
||||
type: tempNode,
|
||||
sourcePath: filePath,
|
||||
sourcePath,
|
||||
};
|
||||
}
|
||||
|
||||
@@ -137,22 +127,18 @@ export class WorkflowRunnerProcess {
|
||||
const credentialsTypeData: ICredentialTypeData = {};
|
||||
// eslint-disable-next-line no-restricted-syntax
|
||||
for (const credentialTypeName of Object.keys(this.data.credentialsTypeData)) {
|
||||
className = this.data.credentialsTypeData[credentialTypeName].className;
|
||||
|
||||
filePath = this.data.credentialsTypeData[credentialTypeName].sourcePath;
|
||||
// eslint-disable-next-line @typescript-eslint/no-unsafe-assignment, import/no-dynamic-require, global-require, @typescript-eslint/no-var-requires
|
||||
const tempModule = require(filePath);
|
||||
let tempCredential: ICredentialType;
|
||||
const { className, sourcePath } = this.data.credentialsTypeData[credentialTypeName];
|
||||
|
||||
try {
|
||||
// eslint-disable-next-line @typescript-eslint/no-unsafe-call
|
||||
tempCredential = new tempModule[className]() as ICredentialType;
|
||||
tempCredential = loadClassInIsolation(sourcePath, className);
|
||||
} catch (error) {
|
||||
throw new Error(`Error loading credential "${credentialTypeName}" from: "${filePath}"`);
|
||||
throw new Error(`Error loading credential "${credentialTypeName}" from: "${sourcePath}"`);
|
||||
}
|
||||
|
||||
credentialsTypeData[credentialTypeName] = {
|
||||
type: tempCredential,
|
||||
sourcePath: filePath,
|
||||
sourcePath,
|
||||
};
|
||||
}
|
||||
|
||||
|
||||
Reference in New Issue
Block a user