mirror of
https://github.com/Abdulazizzn/n8n-enterprise-unlocked.git
synced 2025-12-17 01:56:46 +00:00
feat(core): Lazy-load nodes and credentials to reduce baseline memory usage (#4577)
This commit is contained in:
committed by
GitHub
parent
f63cd3b89e
commit
b6c57e19fc
@@ -4,7 +4,7 @@ import { existsSync } from 'fs';
|
||||
import bodyParser from 'body-parser';
|
||||
import { CronJob } from 'cron';
|
||||
import express from 'express';
|
||||
import { set } from 'lodash';
|
||||
import set from 'lodash.set';
|
||||
import { BinaryDataManager, UserSettings } from 'n8n-core';
|
||||
import {
|
||||
ICredentialType,
|
||||
@@ -13,8 +13,7 @@ import {
|
||||
INode,
|
||||
INodeExecutionData,
|
||||
INodeParameters,
|
||||
INodeTypeData,
|
||||
INodeTypes,
|
||||
INodesAndCredentials,
|
||||
ITriggerFunctions,
|
||||
ITriggerResponse,
|
||||
LoggerProxy,
|
||||
@@ -67,6 +66,14 @@ import type {
|
||||
PostgresSchemaSection,
|
||||
} from './types';
|
||||
|
||||
const loadNodesAndCredentials: INodesAndCredentials = {
|
||||
loaded: { nodes: {}, credentials: {} },
|
||||
known: { nodes: {}, credentials: {} },
|
||||
};
|
||||
|
||||
const mockNodeTypes = NodeTypes(loadNodesAndCredentials);
|
||||
CredentialTypes(loadNodesAndCredentials);
|
||||
|
||||
/**
|
||||
* Initialize a test server.
|
||||
*
|
||||
@@ -149,8 +156,6 @@ export async function initTestServer({
|
||||
* Pre-requisite: Mock the telemetry module before calling.
|
||||
*/
|
||||
export function initTestTelemetry() {
|
||||
const mockNodeTypes = { nodeTypes: {} } as INodeTypes;
|
||||
|
||||
void InternalHooksManager.init('test-instance-id', 'test-version', mockNodeTypes);
|
||||
}
|
||||
|
||||
@@ -217,20 +222,19 @@ export function gitHubCredentialType(): ICredentialType {
|
||||
* Initialize node types.
|
||||
*/
|
||||
export async function initCredentialsTypes(): Promise<void> {
|
||||
const credentialTypes = CredentialTypes();
|
||||
await credentialTypes.init({
|
||||
loadNodesAndCredentials.loaded.credentials = {
|
||||
githubApi: {
|
||||
type: gitHubCredentialType(),
|
||||
sourcePath: '',
|
||||
},
|
||||
});
|
||||
};
|
||||
}
|
||||
|
||||
/**
|
||||
* Initialize node types.
|
||||
*/
|
||||
export async function initNodeTypes() {
|
||||
const types: INodeTypeData = {
|
||||
loadNodesAndCredentials.loaded.nodes = {
|
||||
'n8n-nodes-base.start': {
|
||||
sourcePath: '',
|
||||
type: {
|
||||
@@ -524,8 +528,6 @@ export async function initNodeTypes() {
|
||||
},
|
||||
},
|
||||
};
|
||||
|
||||
await NodeTypes().init(types);
|
||||
}
|
||||
|
||||
/**
|
||||
|
||||
Reference in New Issue
Block a user