2024-10-29 03:39:31 -07:00
|
|
|
import { ApplicationError } from 'n8n-workflow';
|
|
|
|
|
|
|
|
import type { TaskRunner } from '../task-broker.service';
|
|
|
|
|
|
|
|
export class TaskRunnerOomError extends ApplicationError {
|
|
|
|
public description: string;
|
|
|
|
|
2024-11-08 10:27:37 -08:00
|
|
|
constructor(
|
|
|
|
public readonly runnerId: TaskRunner['id'],
|
|
|
|
isCloudDeployment: boolean,
|
|
|
|
) {
|
|
|
|
super('Node ran out of memory.', { level: 'error' });
|
2024-10-29 03:39:31 -07:00
|
|
|
|
|
|
|
const fixSuggestions = {
|
2024-11-08 10:27:37 -08:00
|
|
|
reduceItems:
|
|
|
|
'Reduce the number of items processed at a time, by batching them using a loop node',
|
2024-10-29 03:39:31 -07:00
|
|
|
increaseMemory:
|
2024-11-08 10:27:37 -08:00
|
|
|
"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',
|
2024-10-29 03:39:31 -07:00
|
|
|
};
|
|
|
|
|
|
|
|
const subtitle =
|
2024-11-08 10:27:37 -08:00
|
|
|
'This usually happens when there are too many items to process. You can try the following:';
|
2024-10-29 03:39:31 -07:00
|
|
|
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;
|
|
|
|
}
|
|
|
|
}
|