diff --git a/docker/images/n8n/n8n-task-runners.json b/docker/images/n8n/n8n-task-runners.json index 10cf338731..aacd253680 100644 --- a/docker/images/n8n/n8n-task-runners.json +++ b/docker/images/n8n/n8n-task-runners.json @@ -8,7 +8,7 @@ "allowed-env": [ "PATH", "N8N_RUNNERS_GRANT_TOKEN", - "N8N_RUNNERS_N8N_URI", + "N8N_RUNNERS_TASK_BROKER_URI", "N8N_RUNNERS_MAX_PAYLOAD", "N8N_RUNNERS_MAX_CONCURRENCY", "N8N_RUNNERS_SERVER_ENABLED", diff --git a/packages/@n8n/task-runner/src/config/base-runner-config.ts b/packages/@n8n/task-runner/src/config/base-runner-config.ts index 723d3279bf..6e5ab01632 100644 --- a/packages/@n8n/task-runner/src/config/base-runner-config.ts +++ b/packages/@n8n/task-runner/src/config/base-runner-config.ts @@ -14,8 +14,8 @@ class HealthcheckServerConfig { @Config export class BaseRunnerConfig { - @Env('N8N_RUNNERS_N8N_URI') - n8nUri: string = '127.0.0.1:5679'; + @Env('N8N_RUNNERS_TASK_BROKER_URI') + taskBrokerUri: string = '127.0.0.1:5679'; @Env('N8N_RUNNERS_GRANT_TOKEN') grantToken: string = ''; diff --git a/packages/@n8n/task-runner/src/js-task-runner/__tests__/js-task-runner.test.ts b/packages/@n8n/task-runner/src/js-task-runner/__tests__/js-task-runner.test.ts index 05e0b91f77..d4f75fbf2d 100644 --- a/packages/@n8n/task-runner/src/js-task-runner/__tests__/js-task-runner.test.ts +++ b/packages/@n8n/task-runner/src/js-task-runner/__tests__/js-task-runner.test.ts @@ -34,7 +34,7 @@ describe('JsTaskRunner', () => { ...defaultConfig.baseRunnerConfig, grantToken: 'grantToken', maxConcurrency: 1, - n8nUri: 'localhost', + taskBrokerUri: 'localhost', ...baseRunnerOpts, }, jsRunnerConfig: { @@ -311,10 +311,10 @@ describe('JsTaskRunner', () => { }); it("should not expose task runner's env variables even if no env state is received", async () => { - process.env.N8N_RUNNERS_N8N_URI = 'http://127.0.0.1:5679'; + process.env.N8N_RUNNERS_TASK_BROKER_URI = 'http://127.0.0.1:5679'; const outcome = await execTaskWithParams({ task: newTaskWithSettings({ - code: 'return { val: $env.N8N_RUNNERS_N8N_URI }', + code: 'return { val: $env.N8N_RUNNERS_TASK_BROKER_URI }', nodeMode: 'runOnceForAllItems', }), taskData: newDataRequestResponse(inputItems.map(wrapIntoJson), { diff --git a/packages/@n8n/task-runner/src/task-runner.ts b/packages/@n8n/task-runner/src/task-runner.ts index 1486af280d..b2a8a25e58 100644 --- a/packages/@n8n/task-runner/src/task-runner.ts +++ b/packages/@n8n/task-runner/src/task-runner.ts @@ -92,7 +92,7 @@ export abstract class TaskRunner extends EventEmitter { this.maxConcurrency = opts.maxConcurrency; this.idleTimeout = opts.idleTimeout; - const wsUrl = `ws://${opts.n8nUri}/runners/_ws?id=${this.id}`; + const wsUrl = `ws://${opts.taskBrokerUri}/runners/_ws?id=${this.id}`; this.ws = new WebSocket(wsUrl, { headers: { authorization: `Bearer ${opts.grantToken}`, @@ -109,11 +109,11 @@ export abstract class TaskRunner extends EventEmitter { ['ECONNREFUSED', 'ENOTFOUND'].some((code) => code === error.code) ) { console.error( - `Error: Failed to connect to n8n. Please ensure n8n is reachable at: ${opts.n8nUri}`, + `Error: Failed to connect to n8n. Please ensure n8n is reachable at: ${opts.taskBrokerUri}`, ); process.exit(1); } else { - console.error(`Error: Failed to connect to n8n at ${opts.n8nUri}`); + console.error(`Error: Failed to connect to n8n at ${opts.taskBrokerUri}`); console.error('Details:', event.message || 'Unknown error'); } }); diff --git a/packages/cli/src/runners/task-runner-process.ts b/packages/cli/src/runners/task-runner-process.ts index 01e351c0e4..e45039f547 100644 --- a/packages/cli/src/runners/task-runner-process.ts +++ b/packages/cli/src/runners/task-runner-process.ts @@ -94,19 +94,19 @@ export class TaskRunnerProcess extends TypedEmitter { const grantToken = await this.authService.createGrantToken(); - const n8nUri = `127.0.0.1:${this.runnerConfig.port}`; - this.process = this.startNode(grantToken, n8nUri); + const taskBrokerUri = `127.0.0.1:${this.runnerConfig.port}`; + this.process = this.startNode(grantToken, taskBrokerUri); forwardToLogger(this.logger, this.process, '[Task Runner]: '); this.monitorProcess(this.process); } - startNode(grantToken: string, n8nUri: string) { + startNode(grantToken: string, taskBrokerUri: string) { const startScript = require.resolve('@n8n/task-runner/start'); return spawn('node', [startScript], { - env: this.getProcessEnvVars(grantToken, n8nUri), + env: this.getProcessEnvVars(grantToken, taskBrokerUri), }); } @@ -158,10 +158,10 @@ export class TaskRunnerProcess extends TypedEmitter { } } - private getProcessEnvVars(grantToken: string, n8nUri: string) { + private getProcessEnvVars(grantToken: string, taskBrokerUri: string) { const envVars: Record = { N8N_RUNNERS_GRANT_TOKEN: grantToken, - N8N_RUNNERS_N8N_URI: n8nUri, + N8N_RUNNERS_TASK_BROKER_URI: taskBrokerUri, N8N_RUNNERS_MAX_PAYLOAD: this.runnerConfig.maxPayload.toString(), N8N_RUNNERS_MAX_CONCURRENCY: this.runnerConfig.maxConcurrency.toString(), ...this.getPassthroughEnvVars(),