maxtaco / coffee-script

IcedCoffeeScript
http://maxtaco.github.com/coffee-script
MIT License
726 stars 58 forks source link

Max call stack size exceeded. #66

Closed vjpr closed 11 years ago

vjpr commented 11 years ago

I receive the Max call stack size exceeded after ~20 loops in series of my program.

Normally I would call process.nextTick to clear my stack when running a big loop in series.

Here is the code I am using. Shouldn't this prevent any call stack issue or am I doing something wrong?

for actData in acts
  break if actData.files?
  await asyncFunction defer e, data
  return done e if e
  actData.files = data.files
  await process.nextTick defer()

The error is not correlated with a particular element in the array - I have received the error on different elements when running the function from different contexts.


When I replace it with code using the async library it still fails. Code can be found below:

fn = (done) ->
  async.eachSeries acts, (actData, cb) ->
    return cb() if actData.files?
    ComLaw.downloadAct actData.ComlawId,
      downloadDir: downloadedFilesDir
    , (e, data) ->
      return cb e if e
      # Path to downloaded files. HTML or RTF.
      actData.files = data.files
      process.nextTick cb
  , done

await fn defer e
return done e if e

If I change it to async.each it still happens.

vjpr commented 11 years ago

My fault. It was my use of the cheerio library deep in my code. Not sure why I wasn't getting stack traces though.