@me108 What is your queue driver on the windows instance? Check the QUEUE_CONNECTION setting in your .env. If it's set to sync on the other instances it might explain why you're seeing the output as it'll immediately run the job. If it's set to something else on Windows, it'll be queued and sent to a background worker so you won't see the echo within the terminal.
Job fails silently on exception, nothing is logged
I have a weird issue with my Laravel 10 project on Windows 11.
When a job throws an exception, Laravel just quits silently without logging anything to /storage/logs/laravel.log. It also ignores try-catch blocks and quits the execution nontheless.
It wasn't always like that. It worked in the past. But I can't remember when it stopped and what I might have changed, except from adding / removing some packages.
This problem effects only Jobs. Exceptions that may occur in Controllers are handled properly. They are either thrown or caught and are logged to the laravel.log file.
/app/Jobs/TestJob.php
<?php
namespace App\Jobs;
...
class TestJob implements ShouldQueue
{
use Dispatchable, InteractsWithQueue, Queueable, SerializesModels;
/**
* Create a new job instance.
*/
public function __construct()
{
//
}
/**
* Execute the job.
*/
public function handle(): void
{
try
{
echo sprintf( "%f\n", 100 / 0 );
echo "This line is never reached.\n";
}
catch (\Throwable $t)
{
echo "There was an exception which was caught.\n";
}
}
}
C:\Work\MyProject>php artisan:test
Which command would you like to run?
App\Jobs\TestJob ..................................................... 0
❯ 0
Running [App\Jobs\TestJob]
C:\Work\MyProject>
When I create a single PHP file in the folder with the same exception and run it via php -f exception.php it works as expected:
C:\Work\MyProject>php -f .\exception.php
There was an exception which was caught.
C:\Work\MyProject>
When I use a different environment (MacOS, Ubuntu) and run the same scenario, it works as expected aswell.
user@MyMacBook MyProject % ./artisan schedule:test
Which command would you like to run?
App\Jobs\TestJob
Running [App\Jobs\TestJob] There was an exception which was caught. ....................... 19ms DONE
user@MyMacBook MyProject %
I already tried switching PHP versions. On Windows I run PHP 8.3.14. On MacOS it is 8.2.4. But without success.
What could be the issue here?
Please or to participate in this conversation.