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

Undefined/empty jobs #248

Open
jaschaio opened this issue Aug 2, 2020 · 15 comments · May be fixed by #1395
Open

Undefined/empty jobs #248

jaschaio opened this issue Aug 2, 2020 · 15 comments · May be fixed by #1395

Comments

@jaschaio
Copy link

jaschaio commented Aug 2, 2020

I am having a lot of failed jobs, but when I try to get them via:

const jobs = await queue.getJobs( [ 'failed' ] );

They are returned as undefined. e.G.:

[ undefined, undefined, undefined, ... ]

As I can't get the job ID this way, I double checked which keys it is trying to get by setting process.env.DEBUG = "ioredis:*";. When I manually check one of the keys that returns an undefined job via the redis-cli I get an empty result:

HGETALL bull:short:825F243AD7000000CF2B022C0100296E5A100417BA75E26AFC434291F746A7608C065246645F696400645F243AD7DE5C4A0015CB2CDD0004
(empty array)

Any reason how this could happen or how I could investigate further?

@Anushil98
Copy link

same here please help !!!!!

@manast
Copy link
Contributor

manast commented Sep 6, 2020

Can you provide some code that reproduces the issue?

@Anushil98
Copy link

Our team used Bull to solve the issue we had used a similar code snippet as mentioned in the first comment.
In our use case we tried to use the getJobs and getWaiting for fetching the last n jobs in the queue inside a cron job for a certain purpose. The getWaitingCount gives us the correct job count but when we use the getJobs we get an array of undefined jobs. The main issue here is that this exact use case works in bull but not in bullmq.

Code couldn't be shown due to confidential information.
Thanks for responding.

@manast
Copy link
Contributor

manast commented Sep 10, 2020

you do not need to provide code that is confidential, just a test case that demonstrates the issue. Thing is, we have tests that cover this case and it works, so it must be something else that affects the results:
https://github.com/taskforcesh/bullmq/blob/master/src/test/test_getters.ts

@swordensen
Copy link

swordensen commented Mar 23, 2021

I ran into a similar issue with the 'repeat' job type. I expected getJobs to return an array of jobs but, instead I got an array of 'undefined' which is weird.

I wrote a test inside test_getters.ts like manast suggested to make sure I'm not crazy.

  it('should return repeat jobs', async function(done) {
    try {
      await queue.add(
        'test',
        { foo: 1 },
        {
          repeat: {
            every: 15000,
          },
        },
      );

      const jobs = await queue.getJobs('repeat');
      console.log(jobs);
      expect(jobs[0]?.data?.foo).to.equal(1);
    } catch (e) {
      return done(e);
    }
  });

image

Anyway, I hope this issue gets resolved soon since I'd like more data than what the getRepeatableJobs() call gives me.

@swordensen
Copy link

literally minutes after posting I realized that the job type I'm looking for is "delayed" not "repeat" smh. I'll leave my post in case any other google wanderers run into the same problem lol.

@cchepeau-mwb
Copy link

I'm having the same exact issue. :(

redis 6.2
bullmq 1.77.1

@cchepeau-mwb
Copy link

OK nvm. I was wrongly using redis prefixes at the connection options... bull wasn't able to retrieve the jobs data..

@BohdanKov
Copy link

I have a similar problem. I am getting an undefined in an array when calling getJobs(). It happens every time when I try to create a delayed job.

redis 7.0
bullmq 3.2.2

@manast
Copy link
Contributor

manast commented Nov 21, 2022

@BohdanKov can you please create a minimal reproducible case and a new issue with the test code?

@BohdanKov
Copy link

@BohdanKov can you please create a minimal reproducible case and a new issue with the test code?

@manast created an issue #1546

@roggervalf
Copy link
Collaborator

I think it should be related to our new marker strategy for delayed jobs, there is an special id '0:${delay}', this value is added in wait list when the list is empty and delayed jobs are added, so the worker wakes up and it can know how much time has to wait until promote the delayed job. As this value is only used for this purpose, it is not related to any job info, so in getJobs function this value will be null

@maraujop
Copy link

maraujop commented Mar 30, 2023

And is there any workaround or fix for that? Thanks in advance

@yamiyukiharu
Copy link

having this issue as well, +1

@roggervalf
Copy link
Collaborator

roggervalf commented Aug 22, 2023

Hey, we added this change to skip delayed markers 816376e some time ago, in case you are using a greater version than 3.1.3 a reproducible test case could help us to make a fix

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

Successfully merging a pull request may close this issue.

9 participants