2

I'm using Laravel Valet for my Craft development environment (which is awesome, btw) except for an issue with Tasks not kicking off. I initially stumbled upon the problem while using the Import plugin. The task created by the plugin would never start. Instead, it would sit in a "Pending" state.

I figured this was a bug with the plugin, because other tasks seemed to start and run just fine. I then also discovered another task-related problem with P&T's example task plugin, "Power Nap", where running the task would cause the whole site to hang.

What gives?

Both of these issues aren't present when running the site with MAMP. I've narrowed it down to something to do with Valet (which is using Caddy to serve PHP sites).

1

The issue seemed to stem from the fact that Caddy serves up PHP with fastcgi, instead of Apache or Nginx, and something to do with http requests used to start the task. AJAX requests (what my other functioning task plugins were using to kickoff) were unaffected.

Following a suggestion found here: https://stackoverflow.com/questions/11758334/fastcgi-finish-request-creates-hung-connection-when-open-session-exists

I've placed

session_write_close();
fastcgi_finish_request();

at the top of the runStep($step) function in each plugin's Task class and it resolved the issue! Though, I'm not sure if either of the lines above have other implications.


Update
I should add, that from what I can tell, the above snippet does cause issues with tasks on Apache setups. (tasks will start yet never finish). Unless you are using Caddy Server in production, (you're probably not and using Valet for development) the snippet above should only be used as a temporary hack to get through your tasks.

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service, privacy policy and cookie policy

Not the answer you're looking for? Browse other questions tagged or ask your own question.