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

add null check when job is undefined #139

Merged
merged 1 commit into from
Jan 14, 2021

Conversation

hisabimbola
Copy link

This fixes a case where bull returns null for a job. I am not sure why bull does that but this PR adds a null check to prevent the app from crashing

fixes #43

@@ -70,7 +70,7 @@ module.exports = async function getDataForQeues({ queues, query = {} }) {
return {
name,
counts,
jobs: jobs.map(formatJob),
jobs: jobs.filter((job) => !!job).map(formatJob),
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

A reduce instead of a filter -> map would reduce the iteration count by up to 2x 🙂

I'd recommend going with that instead for this case!

Copy link

@robman87 robman87 Nov 25, 2020

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

return {
      name,
      counts,
      jobs: jobs
        .reduce((result, job) => {
          if (job) {
            result.push(formatJob(job))
          }
          return result
        }, [])
    }

Copy link
Owner

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I don't agree with you, this consumes 2x memory, it is better to use filter & map as it is more declarative

@lukepolo
Copy link

To avoid this error for now you can remove removeOnComplete ... gross but i only use bull board for dev so not a huge deal.

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.

5 participants