n8n/packages/cli/src/runners/errors/task-runner-oom-error.ts
Tomi Turtiainen 0fdb79a270
Some checks failed
Test Master / install-and-build (push) Has been cancelled
Test Master / Unit tests (18.x) (push) Has been cancelled
Test Master / Unit tests (20.x) (push) Has been cancelled
Test Master / Unit tests (22.4) (push) Has been cancelled
Test Master / Lint (push) Has been cancelled
Test Master / Notify Slack on failure (push) Has been cancelled
fix(core): Make task runner oom error message more user friendly (no-changelog) (#11646)
2024-11-08 20:27:37 +02:00

36 lines
1.2 KiB
TypeScript

import { ApplicationError } from 'n8n-workflow';
import type { TaskRunner } from '../task-broker.service';
export class TaskRunnerOomError extends ApplicationError {
public description: string;
constructor(
public readonly runnerId: TaskRunner['id'],
isCloudDeployment: boolean,
) {
super('Node ran out of memory.', { level: 'error' });
const fixSuggestions = {
reduceItems:
'Reduce the number of items processed at a time, by batching them using a loop node',
increaseMemory:
"Increase the memory available to the task runner with 'N8N_RUNNERS_MAX_OLD_SPACE_SIZE' environment variable",
upgradePlan: 'Upgrade your cloud plan to increase the available memory',
};
const subtitle =
'This usually happens when there are too many items to process. You can try the following:';
const suggestions = isCloudDeployment
? [fixSuggestions.reduceItems, fixSuggestions.upgradePlan]
: [fixSuggestions.reduceItems, fixSuggestions.increaseMemory];
const suggestionsText = suggestions
.map((suggestion, index) => `${index + 1}. ${suggestion}`)
.join('<br/>');
const description = `${subtitle}<br/><br/>${suggestionsText}`;
this.description = description;
}
}