5

If I compile a very large file with solc the stack overflows. This will happen most commonly in node because the default stack is only 984kbytes, which is strangely what you would expect for a 1990s era program, except node isn't 1990s.

This is the error you get: not ok 1 RangeError: Maximum call stack size exceeded

It is likely that the the javascript wrapper solc is using has an O(n) stack behavior, e.g. recursive function.

  • I had this issue and ended up using this solution: stackoverflow.com/a/44398946/1937418 – bingen Feb 16 at 20:36
  • @bingen see answer below. Portability and upgrade issues with overriding the default node location. In these days of Docker however it's probably the way to go provided you use a docker container to run node. – Paul S Feb 17 at 7:10
3

Thanks for this!

Ended up doing: node --stack-size=4096 .\node_modules\truffle\build\cli.bundled.js compile,

instead of truffle compile (after taking a look in node_modules/.bin/truffle).

EDIT: on Ubuntu this works too: node --stack-size=4096 node_modules/.bin/truffle compile

1

This works from the command line, but is very awkward:

alias node='node --stack-size=4096'

It's awkward because you have to specify the stack size anywhere you invoke node, and on most systems you can't put the option in a shebang. E.g. any node utilities such as mocha or tape won't easily work as intended.

You could override 'node' in your path but that's not very portable, you have to remember to do this in your production as well as dev and staging environments.

It would be nice if it was an environment variable but node doesn't support that.

The other option is to break up your solidity code into multiple files, which will be easier once import works portably.

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service, privacy policy and cookie policy

Not the answer you're looking for? Browse other questions tagged or ask your own question.