Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Added 'done' var to prevent this.async()() to be called twice when keepalive is true #15

Closed
wants to merge 2 commits into from

Conversation

amercier
Copy link
Contributor

@amercier amercier commented Dec 7, 2013

With a simple Gruntfile like this:

    grunt.initConfig({
        php: {
            options: {
                port: 8000,
                // hostname: '0.0.0.0'
                hostname: '127.0.0.1'
            },
            server: {
                options: {
                    base: '.',
                }
            },
        }
    });

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?

@sindresorhus
Copy link
Owner

I'm not sure. Can you reproduce your problem in a unit test?

@amercier
Copy link
Contributor Author

Can't reproduce the bug now. Maybe related to some other bug. Closing.

@amercier amercier closed this Dec 14, 2013
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

2 participants