feat(core): Lazy-load nodes and credentials to reduce baseline memory usage (#4577)

This commit is contained in:
कारतोफ्फेलस्क्रिप्ट™
2022-11-23 16:20:28 +01:00
committed by GitHub
parent f63cd3b89e
commit b6c57e19fc
71 changed files with 1102 additions and 1279 deletions

View File

@@ -7,6 +7,7 @@
import express from 'express';
import { join as pathJoin } from 'path';
import { readFile as fsReadFile } from 'fs/promises';
import type { n8n } from 'n8n-core';
import {
ExecutionError,
IDataObject,
@@ -25,7 +26,6 @@ import {
IExecutionFlattedDb,
IPackageVersions,
IWorkflowDb,
IN8nNodePackageJson,
} from '@/Interfaces';
import * as ResponseHelper from '@/ResponseHelper';
// eslint-disable-next-line import/order
@@ -64,7 +64,6 @@ export function getSessionId(req: express.Request): string | undefined {
/**
* Returns information which version of the packages are installed
*
*/
export async function getVersions(): Promise<IPackageVersions> {
if (versionCache !== undefined) {
@@ -72,11 +71,9 @@ export async function getVersions(): Promise<IPackageVersions> {
}
const packageFile = await fsReadFile(pathJoin(CLI_DIR, 'package.json'), 'utf8');
// eslint-disable-next-line @typescript-eslint/no-unsafe-assignment
const packageData = jsonParse<IN8nNodePackageJson>(packageFile);
const packageData = jsonParse<n8n.PackageJson>(packageFile);
versionCache = {
// eslint-disable-next-line @typescript-eslint/no-unsafe-assignment
cli: packageData.version,
};