yookoala / gofast

gofast is a FastCGI "client" library written purely in go
BSD 3-Clause "New" or "Revised" License
224 stars 49 forks source link

gofast hangs on error_log() in php script #28

Closed ijt closed 6 years ago

ijt commented 6 years ago

I made a script like this:

$ cat index.php 
<?php error_log('uh oh');

When I ran my gofast app with php-fpm on this script, and then hit it with curl localhost:8081, it issued the following error and then no longer responded to requests:

2018/07/05 03:23:39 gofast: error stream from application process PHP message: uh oh
ijt commented 6 years ago

I see that Travis is failing for my pull request like this:

--- FAIL: TestClient_canceled (0.00s) client_test.go:98: cancel effective client_test.go:158: expected "gofast: timeout or canceled", got ""

for Go versions 1.8 and 1.9, but when I tried to reproduce the failure locally with Go version 1.8 and 1.9.7, the tests passed. I don't completely understand this test, so I'm not sure what's wrong here.

yookoala commented 6 years ago

Good think to know that PHP can trigger output to error stream.

Will fix this. Thanks.

yookoala commented 6 years ago

@ijt: I have created a branch to test and fix this, but I cannot reproduce the problem with this script. Can you show me the server-side code also? Thanks.

yookoala commented 6 years ago

Merged error.php into master. Please try the behavior of this script in your environment. Thanks.

ijt commented 6 years ago

I don't understand why you made a different script. Why not use the repro script I provided? It works fine to reproduce the problem. You just have to make another request and it will hang.

yookoala commented 6 years ago

I've tried that script, too. Changing the script content doesn't help reproducing the problem on my platform / Travis CI.

yookoala commented 6 years ago

I suspect the Go code you used might be related to the issue.

ijt commented 6 years ago

Here is a repro case. https://gist.github.com/ijt/dfb2e87087089380f4164ab27991af7c

yookoala commented 6 years ago

Thanks. I've found a way to reproduce the issue, along with a possible fix. Please check #36.