mirror of
https://github.com/Abdulazizzn/n8n-enterprise-unlocked.git
synced 2025-12-18 18:41:14 +00:00
fix(core): Make senderId required for all command messages (#7252)
all commands sent between main instance and workers need to contain a server id to prevent senders from reacting to their own messages, causing loops this PR makes sure all sent messages contain a sender id by default as part of constructing a sending redis client. --------- Co-authored-by: कारतोफ्फेलस्क्रिप्ट™ <aditya@netroy.in>
This commit is contained in:
committed by
GitHub
parent
77d6e3fc07
commit
4b014286cf
@@ -22,6 +22,7 @@ import { PostHogClient } from '@/posthog';
|
||||
import { License } from '@/License';
|
||||
import { ExternalSecretsManager } from '@/ExternalSecrets/ExternalSecretsManager.ee';
|
||||
import { initExpressionEvaluator } from '@/ExpressionEvalator';
|
||||
import { generateHostInstanceId } from '../databases/utils/generators';
|
||||
|
||||
export abstract class BaseCommand extends Command {
|
||||
protected logger = LoggerProxy.init(getLogger());
|
||||
@@ -36,6 +37,10 @@ export abstract class BaseCommand extends Command {
|
||||
|
||||
protected instanceId: string;
|
||||
|
||||
instanceType: N8nInstanceType = 'main';
|
||||
|
||||
queueModeId: string;
|
||||
|
||||
protected server?: AbstractServer;
|
||||
|
||||
async init(): Promise<void> {
|
||||
@@ -83,6 +88,22 @@ export abstract class BaseCommand extends Command {
|
||||
await Container.get(InternalHooks).init(this.instanceId);
|
||||
}
|
||||
|
||||
protected setInstanceType(instanceType: N8nInstanceType) {
|
||||
this.instanceType = instanceType;
|
||||
config.set('generic.instanceType', instanceType);
|
||||
}
|
||||
|
||||
protected setInstanceQueueModeId() {
|
||||
if (config.getEnv('executions.mode') === 'queue') {
|
||||
if (config.get('redis.queueModeId')) {
|
||||
this.queueModeId = config.get('redis.queueModeId');
|
||||
return;
|
||||
}
|
||||
this.queueModeId = generateHostInstanceId(this.instanceType);
|
||||
config.set('redis.queueModeId', this.queueModeId);
|
||||
}
|
||||
}
|
||||
|
||||
protected async stopProcess() {
|
||||
// This needs to be overridden
|
||||
}
|
||||
@@ -115,11 +136,9 @@ export abstract class BaseCommand extends Command {
|
||||
await this.externalHooks.init();
|
||||
}
|
||||
|
||||
async initLicense(instanceType: N8nInstanceType = 'main'): Promise<void> {
|
||||
config.set('generic.instanceType', instanceType);
|
||||
|
||||
async initLicense(): Promise<void> {
|
||||
const license = Container.get(License);
|
||||
await license.init(this.instanceId, instanceType);
|
||||
await license.init(this.instanceId, this.instanceType ?? 'main');
|
||||
|
||||
const activationKey = config.getEnv('license.activationKey');
|
||||
|
||||
|
||||
Reference in New Issue
Block a user