We have a Method looping over a growing collection of documents (with Collection.find().forEach()). Inside of the forEach loop we create new documents and insert them into another collection. This is not meant to be triggered by regular users so it is OK to take long.
We seem to have reached a point where this causes memory problems:
/.../.meteor/local/build/programs/server/packages/meteor.js:1055
Fiber(runWithEnvironment).run();
^
RangeError: Out of memory
at Object._onImmediate (packages/meteor/dynamics_nodejs.js:122:1)
at processImmediate [as _immediateCallback] (timers.js:354:15)
=> Exited with code: 8
Our start script has this option
NODE_OPTIONS="--max-old-space-size=8192"
Is there anything else we could try?
BTW: It is happening most of the time, but once we got this error instead:
Exception while invoking method 'xxx' MongoError: cursor killed or timed out
at Object.Future.wait