When there are tons of users, “RangeError: Maximum call stack size exceeded” occurs and it dies in the middle.
async.eachSeries users, (user, next) ->
user.save (error)->
return next()
, (error) ->
// ...
Wrapping with process.nextTick or setImmediate as shown below resolves it:
async.eachSeries users, (user, next) ->
process.nextTick ->
user.save (error)->
return next()
, (error) ->
// ...
・Node.js - Maximum call stack size exceeded - Stack Overflow
・‘Maximum call stack size exceeded’ using async.forEachLimit · Issue #75 · caolan/async
That’s all from the Gemba.