mirror of
https://github.com/n8n-io/n8n.git
synced 2025-03-05 20:50:17 -08:00
fix(core): Ensure nodes post-processors run in the correct order (#7500)
Fixes #7497
This commit is contained in:
parent
c47d27dd6d
commit
6f45298d3d
|
@ -123,7 +123,7 @@ import { toHttpNodeParameters } from '@/CurlConverterHelper';
|
||||||
import { EventBusController } from '@/eventbus/eventBus.controller';
|
import { EventBusController } from '@/eventbus/eventBus.controller';
|
||||||
import { EventBusControllerEE } from '@/eventbus/eventBus.controller.ee';
|
import { EventBusControllerEE } from '@/eventbus/eventBus.controller.ee';
|
||||||
import { licenseController } from './license/license.controller';
|
import { licenseController } from './license/license.controller';
|
||||||
import { Push, setupPushServer, setupPushHandler } from '@/push';
|
import { setupPushServer, setupPushHandler } from '@/push';
|
||||||
import { setupAuthMiddlewares } from './middlewares';
|
import { setupAuthMiddlewares } from './middlewares';
|
||||||
import { handleLdapInit, isLdapEnabled } from './Ldap/helpers';
|
import { handleLdapInit, isLdapEnabled } from './Ldap/helpers';
|
||||||
import { AbstractServer } from './AbstractServer';
|
import { AbstractServer } from './AbstractServer';
|
||||||
|
@ -171,12 +171,10 @@ export class Server extends AbstractServer {
|
||||||
|
|
||||||
private credentialTypes: ICredentialTypes;
|
private credentialTypes: ICredentialTypes;
|
||||||
|
|
||||||
private frontendService: FrontendService;
|
private frontendService?: FrontendService;
|
||||||
|
|
||||||
private postHog: PostHogClient;
|
private postHog: PostHogClient;
|
||||||
|
|
||||||
private push: Push;
|
|
||||||
|
|
||||||
constructor() {
|
constructor() {
|
||||||
super('main');
|
super('main');
|
||||||
|
|
||||||
|
@ -194,13 +192,8 @@ export class Server extends AbstractServer {
|
||||||
this.nodeTypes = Container.get(NodeTypes);
|
this.nodeTypes = Container.get(NodeTypes);
|
||||||
|
|
||||||
if (!config.getEnv('endpoints.disableUi')) {
|
if (!config.getEnv('endpoints.disableUi')) {
|
||||||
// eslint-disable-next-line @typescript-eslint/naming-convention
|
// eslint-disable-next-line @typescript-eslint/no-var-requires
|
||||||
const { FrontendService } = await import('@/services/frontend.service');
|
this.frontendService = Container.get(require('@/services/frontend.service').FrontendService);
|
||||||
this.frontendService = Container.get(FrontendService);
|
|
||||||
this.loadNodesAndCredentials.addPostProcessor(async () =>
|
|
||||||
this.frontendService.generateTypes(),
|
|
||||||
);
|
|
||||||
await this.frontendService.generateTypes();
|
|
||||||
}
|
}
|
||||||
|
|
||||||
this.activeExecutionsInstance = Container.get(ActiveExecutions);
|
this.activeExecutionsInstance = Container.get(ActiveExecutions);
|
||||||
|
@ -210,8 +203,6 @@ export class Server extends AbstractServer {
|
||||||
this.presetCredentialsLoaded = false;
|
this.presetCredentialsLoaded = false;
|
||||||
this.endpointPresetCredentials = config.getEnv('credentials.overwrite.endpoint');
|
this.endpointPresetCredentials = config.getEnv('credentials.overwrite.endpoint');
|
||||||
|
|
||||||
this.push = Container.get(Push);
|
|
||||||
|
|
||||||
await super.start();
|
await super.start();
|
||||||
LoggerProxy.debug(`Server ID: ${this.uniqueInstanceId}`);
|
LoggerProxy.debug(`Server ID: ${this.uniqueInstanceId}`);
|
||||||
|
|
||||||
|
@ -372,14 +363,17 @@ export class Server extends AbstractServer {
|
||||||
await Container.get(MetricsService).configureMetrics(this.app);
|
await Container.get(MetricsService).configureMetrics(this.app);
|
||||||
}
|
}
|
||||||
|
|
||||||
this.frontendService.addToSettings({
|
const { frontendService } = this;
|
||||||
|
if (frontendService) {
|
||||||
|
frontendService.addToSettings({
|
||||||
isNpmAvailable: await exec('npm --version')
|
isNpmAvailable: await exec('npm --version')
|
||||||
.then(() => true)
|
.then(() => true)
|
||||||
.catch(() => false),
|
.catch(() => false),
|
||||||
versionCli: N8N_VERSION,
|
versionCli: N8N_VERSION,
|
||||||
});
|
});
|
||||||
|
|
||||||
await this.externalHooks.run('frontend.settings', [this.frontendService.getSettings()]);
|
await this.externalHooks.run('frontend.settings', [frontendService.getSettings()]);
|
||||||
|
}
|
||||||
|
|
||||||
await this.postHog.init();
|
await this.postHog.init();
|
||||||
|
|
||||||
|
@ -408,7 +402,9 @@ export class Server extends AbstractServer {
|
||||||
if (isApiEnabled()) {
|
if (isApiEnabled()) {
|
||||||
const { apiRouters, apiLatestVersion } = await loadPublicApiVersions(publicApiEndpoint);
|
const { apiRouters, apiLatestVersion } = await loadPublicApiVersions(publicApiEndpoint);
|
||||||
this.app.use(...apiRouters);
|
this.app.use(...apiRouters);
|
||||||
this.frontendService.settings.publicApi.latestVersion = apiLatestVersion;
|
if (frontendService) {
|
||||||
|
frontendService.settings.publicApi.latestVersion = apiLatestVersion;
|
||||||
|
}
|
||||||
}
|
}
|
||||||
// Parse cookies for easier access
|
// Parse cookies for easier access
|
||||||
this.app.use(cookieParser());
|
this.app.use(cookieParser());
|
||||||
|
@ -1187,17 +1183,21 @@ export class Server extends AbstractServer {
|
||||||
// Settings
|
// Settings
|
||||||
// ----------------------------------------
|
// ----------------------------------------
|
||||||
|
|
||||||
|
if (frontendService) {
|
||||||
// Returns the current settings for the UI
|
// Returns the current settings for the UI
|
||||||
this.app.get(
|
this.app.get(
|
||||||
`/${this.restEndpoint}/settings`,
|
`/${this.restEndpoint}/settings`,
|
||||||
ResponseHelper.send(
|
ResponseHelper.send(
|
||||||
async (req: express.Request, res: express.Response): Promise<IN8nUISettings> => {
|
async (req: express.Request, res: express.Response): Promise<IN8nUISettings> => {
|
||||||
void Container.get(InternalHooks).onFrontendSettingsAPI(req.headers.sessionid as string);
|
void Container.get(InternalHooks).onFrontendSettingsAPI(
|
||||||
|
req.headers.sessionid as string,
|
||||||
|
);
|
||||||
|
|
||||||
return this.frontendService.getSettings();
|
return frontendService.getSettings();
|
||||||
},
|
},
|
||||||
),
|
),
|
||||||
);
|
);
|
||||||
|
}
|
||||||
|
|
||||||
// ----------------------------------------
|
// ----------------------------------------
|
||||||
// EventBus Setup
|
// EventBus Setup
|
||||||
|
@ -1227,7 +1227,7 @@ export class Server extends AbstractServer {
|
||||||
|
|
||||||
Container.get(CredentialsOverwrites).setData(body);
|
Container.get(CredentialsOverwrites).setData(body);
|
||||||
|
|
||||||
await this.frontendService?.generateTypes();
|
await frontendService?.generateTypes();
|
||||||
|
|
||||||
this.presetCredentialsLoaded = true;
|
this.presetCredentialsLoaded = true;
|
||||||
|
|
||||||
|
@ -1239,7 +1239,7 @@ export class Server extends AbstractServer {
|
||||||
);
|
);
|
||||||
}
|
}
|
||||||
|
|
||||||
if (!config.getEnv('endpoints.disableUi')) {
|
if (frontendService) {
|
||||||
const staticOptions: ServeStaticOptions = {
|
const staticOptions: ServeStaticOptions = {
|
||||||
cacheControl: false,
|
cacheControl: false,
|
||||||
setHeaders: (res: express.Response, path: string) => {
|
setHeaders: (res: express.Response, path: string) => {
|
||||||
|
|
|
@ -107,10 +107,8 @@ class WorkflowRunnerProcess {
|
||||||
// Init db since we need to read the license.
|
// Init db since we need to read the license.
|
||||||
await Db.init();
|
await Db.init();
|
||||||
|
|
||||||
const loadNodesAndCredentials = Container.get(LoadNodesAndCredentials);
|
|
||||||
await loadNodesAndCredentials.init();
|
|
||||||
|
|
||||||
const nodeTypes = Container.get(NodeTypes);
|
const nodeTypes = Container.get(NodeTypes);
|
||||||
|
await Container.get(LoadNodesAndCredentials).init();
|
||||||
|
|
||||||
// Load all external hooks
|
// Load all external hooks
|
||||||
const externalHooks = Container.get(ExternalHooks);
|
const externalHooks = Container.get(ExternalHooks);
|
||||||
|
|
|
@ -47,8 +47,8 @@ export abstract class BaseCommand extends Command {
|
||||||
// Make sure the settings exist
|
// Make sure the settings exist
|
||||||
this.instanceSettings = Container.get(InstanceSettings);
|
this.instanceSettings = Container.get(InstanceSettings);
|
||||||
|
|
||||||
await Container.get(LoadNodesAndCredentials).init();
|
|
||||||
this.nodeTypes = Container.get(NodeTypes);
|
this.nodeTypes = Container.get(NodeTypes);
|
||||||
|
await Container.get(LoadNodesAndCredentials).init();
|
||||||
|
|
||||||
await Db.init().catch(async (error: Error) =>
|
await Db.init().catch(async (error: Error) =>
|
||||||
this.exitWithCrash('There was an error initializing DB', error),
|
this.exitWithCrash('There was an error initializing DB', error),
|
||||||
|
|
|
@ -46,6 +46,9 @@ export class FrontendService {
|
||||||
private readonly mailer: UserManagementMailer,
|
private readonly mailer: UserManagementMailer,
|
||||||
private readonly instanceSettings: InstanceSettings,
|
private readonly instanceSettings: InstanceSettings,
|
||||||
) {
|
) {
|
||||||
|
loadNodesAndCredentials.addPostProcessor(async () => this.generateTypes());
|
||||||
|
void this.generateTypes();
|
||||||
|
|
||||||
this.initSettings();
|
this.initSettings();
|
||||||
|
|
||||||
if (config.getEnv('nodes.communityPackages.enabled')) {
|
if (config.getEnv('nodes.communityPackages.enabled')) {
|
||||||
|
|
Loading…
Reference in a new issue