Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Error json decoding payload resulting in "Trying to access array offset on value of type null" #919

Closed
robSIG opened this issue Nov 1, 2020 · 3 comments

Comments

@robSIG
Copy link

robSIG commented Nov 1, 2020

  • Horizon Version: 4.3.5
  • Laravel Version: 7.28.3
  • PHP Version: 7.4.10
  • Redis Driver & Version: predis/phpredis 1.1.6

Description:

We are getting an error:

Trying to access array offset on value of type null

On the following line:

return $this->decoded['id'];

The error originally originates from this line:

$this->decoded = json_decode($value, true);

Where json_decode is returning NULL instead of an Array.

I have no way of knowing how to debug this? Is there some way to catch this error and view the value of $value?

Interestingly restarting supervisor, and thus Horizon, seems to resolve the issue.

Could be a Redis issue of some sort? Perhaps the data is getting truncated in memory?

I'll split my issue into three questions:

  1. Is this a known issue and is there a fix?
  2. Is there some way to debug this and find the value of $value when json_decode is NULL?
  3. Would you accept a PR for throwing an exception similar to:
$this->decoded = json_decode($value, true);
if ($this->decoded === null) {
    throw new EmptyJobPayloadException($value);
}
@robSIG
Copy link
Author

robSIG commented Nov 2, 2020

In regards (2), finding a way to debug this. Everything in the stacktrace comes from the vendor directory so i'm not sure at what point it would be possible to hook in:

vendor/laravel/horizon/src/JobPayload.php:48Illuminate\Foundation\Bootstrap\HandleExceptions::handleError	
vendor/laravel/horizon/src/JobPayload.php:48Laravel\Horizon\JobPayload::id	
vendor/laravel/horizon/src/Repositories/RedisJobRepository.php:427Laravel\Horizon\Repositories\RedisJobRepository::Laravel\Horizon\Repositories\{closure}	
vendor/laravel/framework/src/Illuminate/Support/helpers.php:433tap	
vendor/laravel/framework/src/Illuminate/Redis/Connections/PhpRedisConnection.php:406Illuminate\Redis\Connections\PhpRedisConnection::pipeline	
vendor/laravel/horizon/src/Repositories/RedisJobRepository.php:434Laravel\Horizon\Repositories\RedisJobRepository::migrated	
vendor/laravel/horizon/src/Listeners/MarkJobsAsMigrated.php:36Laravel\Horizon\Listeners\MarkJobsAsMigrated::handle	
[internal]call_user_func_array	
vendor/laravel/framework/src/Illuminate/Events/Dispatcher.php:400Illuminate\Events\Dispatcher::Illuminate\Events\{closure}	
vendor/laravel/framework/src/Illuminate/Events/Dispatcher.php:226Illuminate\Events\Dispatcher::dispatch	
vendor/laravel/horizon/src/RedisQueue.php:155Laravel\Horizon\RedisQueue::event	
vendor/laravel/horizon/src/RedisQueue.php:109Laravel\Horizon\RedisQueue::Laravel\Horizon\{closure}	
vendor/laravel/framework/src/Illuminate/Support/helpers.php:433tap	
vendor/laravel/horizon/src/RedisQueue.php:110Laravel\Horizon\RedisQueue::migrateExpiredJobs	
vendor/laravel/framework/src/Illuminate/Queue/RedisQueue.php:191Illuminate\Queue\RedisQueue::migrate	
vendor/laravel/framework/src/Illuminate/Queue/RedisQueue.php:167Illuminate\Queue\RedisQueue::pop	
vendor/laravel/horizon/src/RedisQueue.php:92Laravel\Horizon\RedisQueue::pop	
vendor/laravel/framework/src/Illuminate/Queue/Worker.php:282Illuminate\Queue\Worker::getNextJob	
vendor/laravel/framework/src/Illuminate/Queue/Worker.php:121Illuminate\Queue\Worker::daemon	
vendor/laravel/framework/src/Illuminate/Queue/Console/WorkCommand.php:112Illuminate\Queue\Console\WorkCommand::runWorker	
vendor/laravel/framework/src/Illuminate/Queue/Console/WorkCommand.php:96Illuminate\Queue\Console\WorkCommand::handle	
vendor/laravel/horizon/src/Console/WorkCommand.php:46Laravel\Horizon\Console\WorkCommand::handle	
[internal]call_user_func_array	
vendor/laravel/framework/src/Illuminate/Container/BoundMethod.php:37Illuminate\Container\BoundMethod::Illuminate\Container\{closure}	
vendor/laravel/framework/src/Illuminate/Container/Util.php:37Illuminate\Container\Util::unwrapIfClosure	
vendor/laravel/framework/src/Illuminate/Container/BoundMethod.php:95Illuminate\Container\BoundMethod::callBoundMethod	
vendor/laravel/framework/src/Illuminate/Container/BoundMethod.php:39Illuminate\Container\BoundMethod::call	
vendor/laravel/framework/src/Illuminate/Container/Container.php:596Illuminate\Container\Container::call	
vendor/laravel/framework/src/Illuminate/Console/Command.php:134Illuminate\Console\Command::execute	
vendor/symfony/console/Command/Command.php:258Symfony\Component\Console\Command\Command::run	
vendor/laravel/framework/src/Illuminate/Console/Command.php:121Illuminate\Console\Command::run	
vendor/symfony/console/Application.php:920Symfony\Component\Console\Application::doRunCommand	
vendor/symfony/console/Application.php:266Symfony\Component\Console\Application::doRun	
vendor/symfony/console/Application.php:142Symfony\Component\Console\Application::run	
vendor/laravel/framework/src/Illuminate/Console/Application.php:93Illuminate\Console\Application::run	
vendor/laravel/framework/src/Illuminate/Foundation/Console/Kernel.php:129Illuminate\Foundation\Console\Kernel::handle	
artisan:37[main]

@driesvints
Copy link
Member

Hey there,

Unfortunately we don't support this version anymore. Please check out our support policy on which versions we are currently supporting. Can you please try to upgrade to the latest version and see if your problem persists? We'll help you out and re-open this issue if so.

Thanks!

@jyxjjj
Copy link

jyxjjj commented Dec 16, 2024

Seems due to redis clusters. Did you {} quoted your queue name?
And due to #924 i should also mention @dimzeta here.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

3 participants