laravel-workflow: Activity doesn't execute

The workflow’s execute() function is called, but not its first activity’s execute() function.

The workflow class method starts with:

    public function execute($email_address = '')
    {
        dump(__CLASS__ . '::execute()', $email_address);

        yield ActivityStub::make(SendEmailAddressVerificationEmailActivity::class, $email_address);

and prints:

"App\Workflows\Tests\VerifyEmailAddress\VerifyEmailAddressWorkflow::execute()"
"test@example.com"

But the activity class method doesn’t print or log anything:

    public function execute($email_address)
    {
        dump(__CLASS__ . '::execute()', $email_address);

        Log::info('Sending to: ' . $email_address);

In the workflows database table all started workflows have status waiting. I’m using Laravel 10.

About this issue

  • Original URL
  • State: closed
  • Created a year ago
  • Comments: 17 (9 by maintainers)

Most upvoted comments

After migrating the database and updating the QUEUE_CONNECTION as described at https://laravel.com/docs/10.x/queues#driver-prerequisites it seems to work. Thanks a lot!

I have updated the documentation. I would recommend database or redis queue driver for testing workflows. The sync driver won’t work. If you want to hack it yourself @florisbosch has graciously provided some code for that. But you won’t be able to use timers if you go that route. I’m going to close this ticket, assuming changing the driver fixes the issue. If not, please feel free to reopen it. Thanks!

Screen Shot 2023-06-01 at 6 56 08 AM

Hi @wq9578 & @rmcdaniel, This issue seems to happen if you work in your local dev environment and have the queue connection set to “sync”. Because the workflow job is running it is not able to start the activity job before the workflow itself is completed.

I’ve made a pull request with a proposal for a possible solution to use the dispatchNow in the activity. See https://github.com/laravel-workflow/laravel-workflow/pull/95

@wq9578 Do you have some time for a video chat so we can screen share? That would be the fastest way to make progress at this point. The major issue right now is that we aren’t getting any error message. So we need to figure out when/where/how it’s silently dying in the middle of the workflow.

See the files at https://gist.github.com/wq9578/5e52bfc9e0e5178aa4eb99aca0ebcd71, and for the versions the log file there.

The queue doesn’t report anything, even with maximum verbosity: php artisan queue:work -vvv.

Console:

php artisan test tests/Feature/EmailVerificationWorkflowTest.php
"App\Workflows\Tests\VerifyEmailAddress\VerifyEmailAddressWorkflow::execute(test@example.com)" // app/Workflows/Tests/VerifyEmailAddress/VerifyEmailAddressWorkflow.php:24

   PASS  Tests\Feature\EmailVerificationWorkflowTest
  ✓ it logs the PHP and composer version                                                                                                         0.11s  
  ✓ it logs the composer package versions with ('laravel/framework')                                                                             0.01s  
  ✓ it logs the composer package versions with ('doctrine/dbal')                                                                                 0.01s  
  ✓ it logs the composer package versions with ('pestphp/pest')                                                                                  0.01s  
  ✓ it logs the composer package versions with ('pestphp/pest-plugin-laravel')
  ✓ it logs the composer package versions with ('laravel-workflow/laravel-workflow')
  ✓ it test the email address verification workflow                                                                                              0.03s  

  Tests:    7 passed (7 assertions)
  Duration: 0.20s

Of course I had started the queue (and I have tested it again now).

The exact instructions were:

  1. Starting the server: php artisan serve
  2. Starting the queue: php artisan queue:work

I also tried starting the queue first, and starting the queue only (without starting the server).

So what is the next step in debugging? The library as well as the website are nicely done, as far as I can see, so I would like to use it. Thanks!