canjs / can-queues

A light weight JavaScript task queue
https://canjs.com/doc/can-queues.html
MIT License
2 stars 2 forks source link

Recursion debugging #24

Open justinbmeyer opened 5 years ago

justinbmeyer commented 5 years ago

Figuring out recursion problems can be a very challenging issue. For example, in https://github.com/canjs/can-stache/issues/650, chrome would crash and it was difficult to figure out what is happening.

I approached this by adding a counter to _logFlush. Once there were over 500 tasks, it would stop running any new tasks and call .logStack().

This pretty much immediately showed me the problem.

I propose we add something like:

queues.stopAfterTaskCount( 500 )

This would only be available in development. You would call stopAfterTaskCount before you have any problems and it would likely die in a meaningful place.