Add configurable HTTP timeout for N8N requests

This commit is contained in:
Oleg Ivaniv 2024-11-28 08:55:17 +01:00
parent 3a5bd12945
commit c6bff40cd6
No known key found for this signature in database
3 changed files with 13 additions and 1 deletions

View file

@ -60,6 +60,12 @@ export const schema = {
default: 3600,
env: 'EXECUTIONS_TIMEOUT_MAX',
},
httpTimeout: {
doc: 'Timeout for HTTP requests (seconds)',
format: Number,
default: 300,
env: 'N8N_HTTP_TIMEOUT',
},
// If a workflow executes all the data gets saved by default. This
// could be a problem when a workflow gets executed a lot and processes

View file

@ -12,3 +12,4 @@ export const CONFIG_FILES = 'N8N_CONFIG_FILES';
export const BINARY_DATA_STORAGE_PATH = 'N8N_BINARY_DATA_STORAGE_PATH';
export const UM_EMAIL_TEMPLATES_INVITE = 'N8N_UM_EMAIL_TEMPLATES_INVITE';
export const UM_EMAIL_TEMPLATES_PWRESET = 'N8N_UM_EMAIL_TEMPLATES_PWRESET';
export const HTTP_TIMEOUT = 'N8N_HTTP_TIMEOUT';

View file

@ -119,6 +119,7 @@ import {
BLOCK_FILE_ACCESS_TO_N8N_FILES,
CONFIG_FILES,
CUSTOM_EXTENSION_ENV,
HTTP_TIMEOUT,
RESTRICT_FILE_ACCESS_TO,
UM_EMAIL_TEMPLATES_INVITE,
UM_EMAIL_TEMPLATES_PWRESET,
@ -140,7 +141,11 @@ import {
import { ScheduledTaskManager } from './ScheduledTaskManager';
import { SSHClientsManager } from './SSHClientsManager';
axios.defaults.timeout = 300000;
// httpTimeout schema config is provided in seconds
axios.defaults.timeout = process.env[HTTP_TIMEOUT]
? parseInt(process.env[HTTP_TIMEOUT]) * 1000
: 300000;
// Prevent axios from adding x-form-www-urlencoded headers by default
axios.defaults.headers.post = {};
axios.defaults.headers.put = {};