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

[2.0] Fix Failed Jobs page showing no results when failed jobs do exist #511

Merged
merged 1 commit into from
Feb 12, 2019
Merged

[2.0] Fix Failed Jobs page showing no results when failed jobs do exist #511

merged 1 commit into from
Feb 12, 2019

Conversation

derekmd
Copy link
Contributor

@derekmd derekmd commented Feb 11, 2019

Fixes: #476, #458, #109

I've seen the Failed Jobs section behave like this since the Horizon beta was released.

The Vue component expects its jobs prop to be an Array but the API endpoint can return an object in its JSON body. A filtered PHP associative array needs to be kept as 0-indexed.

this.$http.get('/horizon/api/jobs/failed?' + tagQuery + 'starting_at=' + starting)
.then(response => {
this.jobs = response.data.jobs;

#476 (comment) has a longer explanation of what I found. I wasn't able to figure out how to recreate the edge case in a PHPUnit test. Do we have an explanation of where this empty payload is coming from when fetching a set of jobs?

return $this->indexJobs(collect($jobs)->filter(function ($job) {
$job = is_array($job) ? array_values($job) : null;
return is_array($job) && $job[0] !== null;
}), $indexFrom);

Does Redis ZRANGE (called in RedisJobRepository@getJobsByType()) sometimes return keys that don't exist? This test attempt didn't seem to indicate that.

The `response.data.jobs` Ajax payload
is sometimes a JavaScript object
instead of an array due to a PHP
associative array being returned.

Ensure the job items are in a
0-indexed array.
@driesvints
Copy link
Member

Do we have an explanation of where this empty payload is coming from when fetching a set of jobs?

Not that I know off.

But this is indeed the correct solution. I just tested this and it indeed needs it to be an array at all times. Can you maybe whip up a test that always expects the collection to not be a key-pair value?

@taylorotwell taylorotwell merged commit dad81ee into laravel:2.0 Feb 12, 2019
@derekmd derekmd deleted the fix-failed-jobs-empty-results branch February 12, 2019 20:30
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.

3 participants