romanzipp / Laravel-Queue-Monitor

Monitoring Laravel Jobs with your Database
https://packagist.org/packages/romanzipp/laravel-queue-monitor
MIT License
720 stars 92 forks source link

Error "Class name must be a valid object or a string" when enabling config cache #30

Closed sidneygijzen closed 4 years ago

sidneygijzen commented 4 years ago

Hello,

First of all: thank you for this package.

During development the package worked without any problems. However I ran into the following error when I deployed to production:

[2020-08-02 14:06:54] production.ERROR: Class name must be a valid object or a string {"exception":"[object] (Symfony\\Component\\Debug\\Exception\\FatalThrowableError(code: 0): Class name must be a valid object or a string at /var/www/my-website/vendor/romanzipp/laravel-queue-monitor/src/Services/QueueMonitor.php:30)

On production I run the application with caching enabled. I noticed when I disabled the configuration cache (php artisan config:clear), the error disappeared and job processing was back to normal.

If it helps, some details about used versions:

I'm afraid I don't know the package that well (yet). Do you have any idea what the cause could be?

Thank you.

The full stacktrace of the error:

[2020-08-02 14:06:54] production.ERROR: Class name must be a valid object or a string {"exception":"[object] (Symfony\\Component\\Debug\\Exception\\FatalThrowableError(code: 0): Class name must be a valid object or a string at /var/www/my-website/vendor/romanzipp/laravel-queue-monitor/src/Services/QueueMonitor.php:30)
[stacktrace]
#0 /var/www/my-website/vendor/romanzipp/laravel-queue-monitor/src/Services/QueueMonitor.php(132): romanzipp\\QueueMonitor\\Services\\QueueMonitor::getModel()
#1 /var/www/my-website/vendor/romanzipp/laravel-queue-monitor/src/Services/QueueMonitor.php(63): romanzipp\\QueueMonitor\\Services\\QueueMonitor::jobFinished(Object(Illuminate\\Queue\\Jobs\\DatabaseJob), true, Object(Symfony\\Component\\Debug\\Exception\\FatalThrowableError))
#2 /var/www/my-website/vendor/romanzipp/laravel-queue-monitor/src/Providers/QueueMonitorProvider.php(61): romanzipp\\QueueMonitor\\Services\\QueueMonitor::handleJobFailed(Object(Illuminate\\Queue\\Events\\JobFailed))
#3 /var/www/my-website/vendor/laravel/framework/src/Illuminate/Events/Dispatcher.php(369): romanzipp\\QueueMonitor\\Providers\\QueueMonitorProvider::romanzipp\\QueueMonitor\\Providers\\{closure}(Object(Illuminate\\Queue\\Events\\JobFailed))
#4 /var/www/my-website/vendor/laravel/framework/src/Illuminate/Events/Dispatcher.php(218): Illuminate\\Events\\Dispatcher->Illuminate\\Events\\{closure}('Illuminate\\\\Queu...', Array)
#5 /var/www/my-website/vendor/laravel/framework/src/Illuminate/Queue/Jobs/Job.php(185): Illuminate\\Events\\Dispatcher->dispatch('Illuminate\\\\Queu...')
#6 /var/www/my-website/vendor/laravel/framework/src/Illuminate/Queue/Worker.php(482): Illuminate\\Queue\\Jobs\\Job->fail(Object(Symfony\\Component\\Debug\\Exception\\FatalThrowableError))
#7 /var/www/my-website/vendor/laravel/framework/src/Illuminate/Queue/Worker.php(469): Illuminate\\Queue\\Worker->failJob(Object(Illuminate\\Queue\\Jobs\\DatabaseJob), Object(Symfony\\Component\\Debug\\Exception\\FatalThrowableError))
#8 /var/www/my-website/vendor/laravel/framework/src/Illuminate/Queue/Worker.php(399): Illuminate\\Queue\\Worker->markJobAsFailedIfWillExceedMaxAttempts('database', Object(Illuminate\\Queue\\Jobs\\DatabaseJob), 1, Object(Symfony\\Component\\Debug\\Exception\\FatalThrowableError))
#9 /var/www/my-website/vendor/laravel/framework/src/Illuminate/Queue/Worker.php(375): Illuminate\\Queue\\Worker->handleJobException('database', Object(Illuminate\\Queue\\Jobs\\DatabaseJob), Object(Illuminate\\Queue\\WorkerOptions), Object(Symfony\\Component\\Debug\\Exception\\FatalThrowableError))
#10 /var/www/my-website/vendor/laravel/framework/src/Illuminate/Queue/Worker.php(314): Illuminate\\Queue\\Worker->process('database', Object(Illuminate\\Queue\\Jobs\\DatabaseJob), Object(Illuminate\\Queue\\WorkerOptions))
#11 /var/www/my-website/vendor/laravel/framework/src/Illuminate/Queue/Worker.php(134): Illuminate\\Queue\\Worker->runJob(Object(Illuminate\\Queue\\Jobs\\DatabaseJob), 'database', Object(Illuminate\\Queue\\WorkerOptions))
#12 /var/www/my-website/vendor/laravel/framework/src/Illuminate/Queue/Console/WorkCommand.php(112): Illuminate\\Queue\\Worker->daemon('database', 'default', Object(Illuminate\\Queue\\WorkerOptions))
#13 /var/www/my-website/vendor/laravel/framework/src/Illuminate/Queue/Console/WorkCommand.php(96): Illuminate\\Queue\\Console\\WorkCommand->runWorker('database', 'default')
#14 [internal function]: Illuminate\\Queue\\Console\\WorkCommand->handle()
#15 /var/www/my-website/vendor/laravel/framework/src/Illuminate/Container/BoundMethod.php(32): call_user_func_array(Array, Array)
#16 /var/www/my-website/vendor/laravel/framework/src/Illuminate/Container/Util.php(36): Illuminate\\Container\\BoundMethod::Illuminate\\Container\\{closure}()
#17 /var/www/my-website/vendor/laravel/framework/src/Illuminate/Container/BoundMethod.php(90): Illuminate\\Container\\Util::unwrapIfClosure(Object(Closure))
#18 /var/www/my-website/vendor/laravel/framework/src/Illuminate/Container/BoundMethod.php(34): Illuminate\\Container\\BoundMethod::callBoundMethod(Object(Illuminate\\Foundation\\Application), Array, Object(Closure))
#19 /var/www/my-website/vendor/laravel/framework/src/Illuminate/Container/Container.php(590): Illuminate\\Container\\BoundMethod::call(Object(Illuminate\\Foundation\\Application), Array, Array, NULL)
#20 /var/www/my-website/vendor/laravel/framework/src/Illuminate/Console/Command.php(134): Illuminate\\Container\\Container->call(Array)
#21 /var/www/my-website/vendor/symfony/console/Command/Command.php(255): Illuminate\\Console\\Command->execute(Object(Symfony\\Component\\Console\\Input\\ArgvInput), Object(Illuminate\\Console\\OutputStyle))
#22 /var/www/my-website/vendor/laravel/framework/src/Illuminate/Console/Command.php(121): Symfony\\Component\\Console\\Command\\Command->run(Object(Symfony\\Component\\Console\\Input\\ArgvInput), Object(Illuminate\\Console\\OutputStyle))
#23 /var/www/my-website/vendor/symfony/console/Application.php(1000): Illuminate\\Console\\Command->run(Object(Symfony\\Component\\Console\\Input\\ArgvInput), Object(Symfony\\Component\\Console\\Output\\ConsoleOutput))
#24 /var/www/my-website/vendor/symfony/console/Application.php(271): Symfony\\Component\\Console\\Application->doRunCommand(Object(Illuminate\\Queue\\Console\\WorkCommand), Object(Symfony\\Component\\Console\\Input\\ArgvInput), Object(Symfony\\Component\\Console\\Output\\ConsoleOutput))
#25 /var/www/my-website/vendor/symfony/console/Application.php(147): Symfony\\Component\\Console\\Application->doRun(Object(Symfony\\Component\\Console\\Input\\ArgvInput), Object(Symfony\\Component\\Console\\Output\\ConsoleOutput))
#26 /var/www/my-website/vendor/laravel/framework/src/Illuminate/Console/Application.php(93): Symfony\\Component\\Console\\Application->run(Object(Symfony\\Component\\Console\\Input\\ArgvInput), Object(Symfony\\Component\\Console\\Output\\ConsoleOutput))
#27 /var/www/my-website/vendor/laravel/framework/src/Illuminate/Foundation/Console/Kernel.php(131): Illuminate\\Console\\Application->run(Object(Symfony\\Component\\Console\\Input\\ArgvInput), Object(Symfony\\Component\\Console\\Output\\ConsoleOutput))
#28 /var/www/my-website/artisan(37): Illuminate\\Foundation\\Console\\Kernel->handle(Object(Symfony\\Component\\Console\\Input\\ArgvInput), Object(Symfony\\Component\\Console\\Output\\ConsoleOutput))
#29 {main}
"} 
romanzipp commented 4 years ago

I've pushed a potential fix in #31 Are you able to reproduce this issue using the new branch?

"romanzipp/laravel-queue-monitor": "dev-fix-cached-config#89147cc325d90ca34976cdcef16e5a8034c1aac9"
sidneygijzen commented 4 years ago

Your PR #31 fixes this issue :+1:

Thanks a lot!