The idea is:
(Self-hosted only)
Setting the preferred stack size of node.js should be a recommended solution step in the documentation for the maximum-stack-size-exceeded-error in the memory-issue-documentation. (With giving a proper warning for unexpected behaviour of course)
Exceeding the stack size is something that will happen rather often for anyone using big datasets. It can also be considered that the docker scipt could start with a bigger stack by default as it currently does not set any node arguments itself:
My use case:
Currently, when working with big data (database queries returning >120.000 results) n8n throws an error stating that the maximum call stack size is exceeded. Trying to research the issue only brings up roughly 6 posts all prompting to split up work.
I think it would be beneficial to add this because:
Almost every forum post hints at splitting up work when running into this error, which I personally think should not be the recommendation in every case. This can overcomplicate otherwise very simple workflows, as well as introduce longer execution times. Automated integration tools are expected to handle big data.
More importantly, the overall call stack error and need to increase the stack trace may indicate an issue regarding code infrastructue that could/should be handled in another way.
Any resources to support this?
▼ GitHub Issue Regarding “–stack_size” In Node
▼ How setting the stack-size affects a recursive function executed /w node:
Code:
let i = 0;
try {
let inc = () => {
i++;
inc()
}
inc();
}
catch(e) {
console.log('Maximum stack size is', i + 1, ' calls');
}
Command Line Output /w different sizes:
PS C:\route\program> node --stack-size=900 test.js
Maximum stack size is 12763 calls
PS C:\route\program> node --stack-size=1800 test.js
Maximum stack size is 25563 calls
PS C:\route\program> node --stack-size=4000 test.js
Maximum stack size is 56852 calls
PS C:\route\program> node --stack-size=8000 test.js
Maximum stack size is 113741 calls
Can you work on this?
I wanted to post this proposition here first so that people looking for solutions may find this. If this is regarded as an accepted solution I can open a PR.