mirror of
https://github.com/Abdulazizzn/n8n-enterprise-unlocked.git
synced 2026-08-28 22:30:37 +02:00
Co-authored-by: Tomi Turtiainen <10324676+tomi@users.noreply.github.com>
33 lines
1.3 KiB
TypeScript
33 lines
1.3 KiB
TypeScript
import { UserError } from 'n8n-workflow';
|
|
|
|
export class TaskRunnerFailedHeartbeatError extends UserError {
|
|
description: string;
|
|
|
|
constructor(heartbeatInterval: number, isSelfHosted: boolean) {
|
|
super('Task execution aborted because runner became unresponsive');
|
|
|
|
const subtitle =
|
|
'The task runner failed to respond as expected, so it was considered unresponsive, and the task was aborted. You can try the following:';
|
|
|
|
const fixes = {
|
|
optimizeScript:
|
|
'Optimize your script to prevent CPU-intensive operations, e.g. by breaking them down into smaller chunks or batch processing.',
|
|
ensureTermination:
|
|
'Ensure that all paths in your script are able to terminate, i.e. no infinite loops.',
|
|
increaseInterval: `If your task can reasonably keep the task runner busy for more than ${heartbeatInterval} ${heartbeatInterval === 1 ? 'second' : 'seconds'}, increase the heartbeat interval using the N8N_RUNNERS_HEARTBEAT_INTERVAL environment variable.`,
|
|
};
|
|
|
|
const suggestions = [fixes.optimizeScript, fixes.ensureTermination];
|
|
|
|
if (isSelfHosted) suggestions.push(fixes.increaseInterval);
|
|
|
|
const suggestionsText = suggestions
|
|
.map((suggestion, index) => `${index + 1}. ${suggestion}`)
|
|
.join('<br/>');
|
|
|
|
const description = `${subtitle}<br/><br/>${suggestionsText}`;
|
|
|
|
this.description = description;
|
|
}
|
|
}
|