You'd hit couchjs
stack size limit. If you're using CouchDB 1.4.0+ his size is limited by 64 MiB by default. You may increase it by specifying -S <number-of-bytes>
option for JavaScript query server in CouchDB config. For instance, to set stack size to 128 MiB your config value will looks like:
[query_servers]
javascript = /usr/bin/couchjs -S 134217728 /usr/share/couchdb/server/main.js
Note, that /usr/bin/couchjs
may be different for you depending on your OS. After adding this changes you need to restart CouchDB.
If you'll try to update JavaScript query server config though HTTP API, make sure to kill
all couchjs
processes from shell to let them apply changes.
If your CouchDB version is <1.4 try to upgrade first.