2

I have a plugin that starts a task and subtasks from a CP widget AJAX call. The tasks are running without a hitch, but for some reason on production, the icon does not appear when the tasks start running unless I refresh the page.

On my local dev site (MAMP), the task icon appears as soon as the code below is called.

I am using this code to start the pending tasks I created:

Craft.cp.runPendingTasks();

Any ideas? Is there a different JS command I should be using?

3
  • I've seen that on some setups with gzip compression enabled (either at the Apache level or at the PHP level). Might be worth checking. – Brad Bell Mar 11 '15 at 22:17
  • Yup, it looks like that is the case. Any thoughts on getting around it? It isn't imperative that the circle displays, but the visual feedback is nice. – Aaron Berkowitz Mar 12 '15 at 20:53
  • We've spent a ton of time looking into it and it comes down to the fact that PHP sucks. Workaround is to set buildwithcraft.com/docs/config-settings#runTasksAutomatically to false and setup an external cron job to trigger tasks. – Brad Bell Mar 12 '15 at 20:55
5

I use this to force the task icon to show up immediately:

Craft.cp.setRunningTaskInfo({
    "id": "task ID",
    "level": "0",
    "description": "description",
    "status": "running",
    "progress": 0
});
Craft.cp.trackTaskProgress();

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.