mirror of
https://github.com/Abdulazizzn/n8n-enterprise-unlocked.git
synced 2025-12-21 03:42:16 +00:00
chore(core): Calculate workflow timeout based on startedAt date of execution (#17137)
This commit is contained in:
@@ -307,10 +307,21 @@ export class WorkflowRunner {
|
||||
this.activeExecutions.attachWorkflowExecution(executionId, workflowExecution);
|
||||
|
||||
if (workflowTimeout > 0) {
|
||||
const timeout = Math.min(workflowTimeout, config.getEnv('executions.maxTimeout')) * 1000; // as seconds
|
||||
executionTimeout = setTimeout(() => {
|
||||
void this.activeExecutions.stopExecution(executionId);
|
||||
}, timeout);
|
||||
let timeout = Math.min(workflowTimeout, config.getEnv('executions.maxTimeout')) * 1000; // as milliseconds
|
||||
if (data.startedAt && data.startedAt instanceof Date) {
|
||||
// If startedAt is set, we calculate the timeout based on the startedAt time
|
||||
// This is useful for executions that were waiting in a waiting state
|
||||
// and we want to ensure the timeout is relative to when the execution started.
|
||||
const now = Date.now();
|
||||
timeout = Math.max(timeout - (now - data.startedAt.getTime()), 0);
|
||||
}
|
||||
if (timeout === 0) {
|
||||
this.activeExecutions.stopExecution(executionId);
|
||||
} else {
|
||||
executionTimeout = setTimeout(() => {
|
||||
void this.activeExecutions.stopExecution(executionId);
|
||||
}, timeout);
|
||||
}
|
||||
}
|
||||
|
||||
workflowExecution
|
||||
|
||||
Reference in New Issue
Block a user