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

[3.0] Fix false jobs causing front-end not to display them #582

Merged
merged 1 commit into from
Apr 28, 2019
Merged

[3.0] Fix false jobs causing front-end not to display them #582

merged 1 commit into from
Apr 28, 2019

Conversation

joecampo
Copy link
Contributor

Fixes #304

I’ve ran into issues while running Horizon in production where some of the failed jobs that are collected from Redis have false as all the values on the job (including name, id, connection etc.). I’m not exactly sure how these occur (possibly from orphan processes?) Screenshot:

image

This creates problem for Horizon’s front-end (gets stuck in loading state). This is because the front-end determines the job’s base name using JavaScript’s string.includes(). Unfortunately, when the id is a boolean this method falls t.includes is not a function

horizon/base.js at 3.0 · laravel/horizon · GitHub

Fix

In the RedisJobRepository getJobs method there is already a check to make sure that the job is an array and the the id of the job isn't null. This PR adds a check to make sure that the id of the job isn't false and filter those out.

return is_array($job) && $job[0] !== null && $job[0] !== false;

Relevant line:

https://github.com/laravel/horizon/blob/3.0/src/Repositories/RedisJobRepository.php#L196

I chose to explicitly check if the id is false as opposed to using PHP's empty() as empty("0") will return true and would filter a job id that is equal to 0.

@taylorotwell taylorotwell merged commit e57d8a6 into laravel:3.0 Apr 28, 2019
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

Successfully merging this pull request may close these issues.

Failed Jobs is loading forever with error "t.includes is not a function"
3 participants