mirror of
https://github.com/Abdulazizzn/n8n-enterprise-unlocked.git
synced 2025-12-16 17:46:45 +00:00
fix(core): Fix task runner's task timeout and heartbeat interval (#14889)
This commit is contained in:
@@ -17,6 +17,7 @@
|
|||||||
"N8N_RUNNERS_MAX_PAYLOAD",
|
"N8N_RUNNERS_MAX_PAYLOAD",
|
||||||
"N8N_RUNNERS_MAX_CONCURRENCY",
|
"N8N_RUNNERS_MAX_CONCURRENCY",
|
||||||
"N8N_RUNNERS_TASK_TIMEOUT",
|
"N8N_RUNNERS_TASK_TIMEOUT",
|
||||||
|
"N8N_RUNNERS_HEARTBEAT_INTERVAL",
|
||||||
"N8N_RUNNERS_HEALTH_CHECK_SERVER_ENABLED",
|
"N8N_RUNNERS_HEALTH_CHECK_SERVER_ENABLED",
|
||||||
"N8N_RUNNERS_HEALTH_CHECK_SERVER_HOST",
|
"N8N_RUNNERS_HEALTH_CHECK_SERVER_HOST",
|
||||||
"N8N_RUNNERS_HEALTH_CHECK_SERVER_PORT",
|
"N8N_RUNNERS_HEALTH_CHECK_SERVER_PORT",
|
||||||
|
|||||||
@@ -120,6 +120,36 @@ describe('TaskRunnerProcess', () => {
|
|||||||
expect(options.env).not.toHaveProperty('NODE_OPTIONS');
|
expect(options.env).not.toHaveProperty('NODE_OPTIONS');
|
||||||
});
|
});
|
||||||
|
|
||||||
|
it('should pass N8N_RUNNERS_TASK_TIMEOUT if set', async () => {
|
||||||
|
jest.spyOn(authService, 'createGrantToken').mockResolvedValue('grantToken');
|
||||||
|
runnerConfig.taskTimeout = 123;
|
||||||
|
|
||||||
|
await taskRunnerProcess.start();
|
||||||
|
|
||||||
|
// @ts-expect-error The type is not correct
|
||||||
|
const options = spawnMock.mock.calls[0][2] as SpawnOptions;
|
||||||
|
expect(options.env).toEqual(
|
||||||
|
expect.objectContaining({
|
||||||
|
N8N_RUNNERS_TASK_TIMEOUT: '123',
|
||||||
|
}),
|
||||||
|
);
|
||||||
|
});
|
||||||
|
|
||||||
|
it('should pass N8N_RUNNERS_HEARTBEAT_INTERVAL if set', async () => {
|
||||||
|
jest.spyOn(authService, 'createGrantToken').mockResolvedValue('grantToken');
|
||||||
|
runnerConfig.heartbeatInterval = 456;
|
||||||
|
|
||||||
|
await taskRunnerProcess.start();
|
||||||
|
|
||||||
|
// @ts-expect-error The type is not correct
|
||||||
|
const options = spawnMock.mock.calls[0][2] as SpawnOptions;
|
||||||
|
expect(options.env).toEqual(
|
||||||
|
expect.objectContaining({
|
||||||
|
N8N_RUNNERS_HEARTBEAT_INTERVAL: '456',
|
||||||
|
}),
|
||||||
|
);
|
||||||
|
});
|
||||||
|
|
||||||
it('should use --disallow-code-generation-from-strings and --disable-proto=delete flags', async () => {
|
it('should use --disallow-code-generation-from-strings and --disable-proto=delete flags', async () => {
|
||||||
jest.spyOn(authService, 'createGrantToken').mockResolvedValue('grantToken');
|
jest.spyOn(authService, 'createGrantToken').mockResolvedValue('grantToken');
|
||||||
|
|
||||||
|
|||||||
@@ -51,6 +51,7 @@ export class TaskRunnerProcess extends TypedEmitter<TaskRunnerProcessEventMap> {
|
|||||||
|
|
||||||
private logger: Logger;
|
private logger: Logger;
|
||||||
|
|
||||||
|
/** Environment variables inherited by the child process from the current environment. */
|
||||||
private readonly passthroughEnvVars = [
|
private readonly passthroughEnvVars = [
|
||||||
'PATH',
|
'PATH',
|
||||||
'HOME', // So home directory can be resolved correctly
|
'HOME', // So home directory can be resolved correctly
|
||||||
@@ -171,6 +172,8 @@ export class TaskRunnerProcess extends TypedEmitter<TaskRunnerProcessEventMap> {
|
|||||||
N8N_RUNNERS_TASK_BROKER_URI: taskBrokerUri,
|
N8N_RUNNERS_TASK_BROKER_URI: taskBrokerUri,
|
||||||
N8N_RUNNERS_MAX_PAYLOAD: this.runnerConfig.maxPayload.toString(),
|
N8N_RUNNERS_MAX_PAYLOAD: this.runnerConfig.maxPayload.toString(),
|
||||||
N8N_RUNNERS_MAX_CONCURRENCY: this.runnerConfig.maxConcurrency.toString(),
|
N8N_RUNNERS_MAX_CONCURRENCY: this.runnerConfig.maxConcurrency.toString(),
|
||||||
|
N8N_RUNNERS_TASK_TIMEOUT: this.runnerConfig.taskTimeout.toString(),
|
||||||
|
N8N_RUNNERS_HEARTBEAT_INTERVAL: this.runnerConfig.heartbeatInterval.toString(),
|
||||||
...this.getPassthroughEnvVars(),
|
...this.getPassthroughEnvVars(),
|
||||||
};
|
};
|
||||||
|
|
||||||
|
|||||||
Reference in New Issue
Block a user