apiengine/seoserver — pull request #8 by richard-flosi (2013-08-21 22:58:36+00:00)
Title: jshint, debug logging, exit on timeout

Hi,

I ran into an issue with phantomjs where a synchronous ajax call is NOT being captured by onResourceReceived which caused the seoserver to balloon out of control never closing phantomjs child processes because the number of requests never matched the number of responses.
See: https://github.com/ariya/phantomjs/issues/11284

In the process of debugging I:
* Cleaned up Javascript var usage and spacing
* Added verbose logging for debugging
* Added config options for verbose logging, checkCompleteInterval, checkCompleteTimeDiff, and checkCompleteTimeout

I found for our js backbone app the 1ms interval and 300ms time lapse to be too quick and moved those variables into the config file so people can tweak them to their needs. I used 1s and 3s (which is probably slower that it needs to be), but that worked well for me. I kept the defaults to the values you currently have (1ms and 300ms). In addition, I added a 10s timeout feature so that it will kill off the phantomjs process if it is waiting for more than 10 seconds (also configurable). If it times out and the requests and responses don't match a message will be logged to help the user check if they perhaps had the same issue I did with a synchronous request that was not calling the onResourceReceived hook.

Setting "verbose" to true in the config will log the request and response details which may help with debugging.

Let me know if you have any questions.

Thanks!