javascriptnode.jsstack-overflowpurescriptspago

How to change the node stack limit for spago?


I am working on a project in PureScript which runs lots of huge and stack-extensive tests via spago test feature. In most cases the recursion is so deep that I reach the limit and the tests fail with RangeError: Maximum call stack size exceeded.

Normally I would just run node with --stack-size=$ALOT flag, but here I don't have direct access to the JavaScript evaluator (have I?). In a different case I would use NODE_OPTIONS env variable, but here it is impossible as said in the error message:

node: --stack-size= is not allowed in NODE_OPTIONS

Is there a way to access node flags in spago or bypass this issue in any other manner? Also, my case cannot be solved with TCO.


Solution

  • The command spago test consists of two steps:

    1. spago build to generate js files in ./output
    2. Run the compiled test code with node

    Step two can be manually accomplished with:

    node --stack-size=40000 -e "require('./output/Test.Main/index').main()"