Added 'done' var to prevent this.async()() to be called twice when keepalive is true #15
Add this suggestion to a batch that can be applied as a single commit.
This suggestion is invalid because no changes were made to the code.
Suggestions cannot be applied while the pull request is closed.
Suggestions cannot be applied while viewing a subset of changes.
Only one suggestion per line can be applied in a batch.
Add this suggestion to a batch that can be applied as a single commit.
Applying suggestions on deleted lines is not supported.
You must change the existing code in this line in order to create a valid suggestion.
Outdated suggestions cannot be applied.
This suggestion has been applied or marked resolved.
Suggestions cannot be applied from pending reviews.
Suggestions cannot be applied on multi-line comments.
Suggestions cannot be applied while the pull request is queued to merge.
Suggestion cannot be applied right now. Please check back later.
With a simple Gruntfile like this:
I have the following result when running grunt:server:keepalive:
Yunnan:grunt-php-test amercier$ grunt php:server:keepalive Running "php:server:keepalive" (php) task PHP 5.4.17 Development Server started at Sat Dec 7 21:06:58 2013 Listening on http://127.0.0.1:8000 Document root is /Users/amercier/Development/grunt-php-test Press Ctrl-C to quit. [Sat Dec 7 21:06:58 2013] 127.0.0.1:64790 [200]: / [Sat Dec 7 21:06:58 2013] 127.0.0.1:64791 [200]: / [Sat Dec 7 21:06:58 2013] 127.0.0.1:64792 [200]: / [Sat Dec 7 21:06:58 2013] 127.0.0.1:64793 [200]: / [Sat Dec 7 21:06:58 2013] 127.0.0.1:64795 [200]: / [Sat Dec 7 21:06:58 2013] 127.0.0.1:64796 [200]: / [Sat Dec 7 21:06:58 2013] 127.0.0.1:64797 [200]: / [Sat Dec 7 21:06:58 2013] 127.0.0.1:64798 [200]: / [Sat Dec 7 21:06:58 2013] 127.0.0.1:64799 [200]: / [Sat Dec 7 21:06:58 2013] 127.0.0.1:64800 [200]: / [Sat Dec 7 21:06:58 2013] 127.0.0.1:64801 [200]: / [Sat Dec 7 21:06:58 2013] 127.0.0.1:64802 [200]: / [Sat Dec 7 21:06:58 2013] 127.0.0.1:64803 [200]: / [Sat Dec 7 21:06:58 2013] 127.0.0.1:64804 [200]: / [Sat Dec 7 21:06:58 2013] 127.0.0.1:64805 [200]: / [Sat Dec 7 21:06:58 2013] 127.0.0.1:64806 [200]: / [Sat Dec 7 21:06:58 2013] 127.0.0.1:64807 [200]: / [Sat Dec 7 21:06:58 2013] 127.0.0.1:64808 [200]: / [Sat Dec 7 21:06:59 2013] 127.0.0.1:64809 [200]: /
As you can see, requests are still being sent (to check if the server is alive), even if we receive a 200 OK from the PHP server.
After a little debugging I found that calling
cb()
at tasks/php.js#L63 triggers the http error event callback at tasks/php.js#L21.I haven't dug further, but this could be due to
this.async
trying to do something while we still are in the http request callback method at tasks/php.js#L17.Well, my solution is not perfect. I would rather prefer to find out what is really occurring. Any ideas?