Skip to content

Infinite Loop #4

@nahtnam

Description

@nahtnam

Hey! My project uses prisma and this looked pretty convenient so I wanted to give it a shot.

I'm facing an issue where the worker is getting stuck in an infinite loop. As soon as I add a job, it prints out an infinite amount of:

2024-06-14T06:50:14.123Z prisma-queue processing job from queue named="email"...
2024-06-14T06:50:14.123Z prisma-queue dequeuing from queue named="email"...
2024-06-14T06:50:14.124Z prisma-queue no jobs found in queue named="email"
2024-06-14T06:50:14.174Z prisma-queue processing job from queue named="email"...
2024-06-14T06:50:14.174Z prisma-queue dequeuing from queue named="email"...
2024-06-14T06:50:14.175Z prisma-queue no jobs found in queue named="email"

I noticed that in the DB, the job is not being removed. NOTE: I'm not awaiting the .start()

Code:

export const emailQueue = createQueue<JobPayload, JobResult>(
  { name: 'email' },
  async (job, client) => {
    const { id, payload } = job;
    console.log(
      `Processing job#${id} with payload=${JSON.stringify(payload)})`,
    );
    // await someAsyncMethod();
    await job.progress(50);
    const status = 200;
    if (Math.random() > 0.5) {
      throw new Error(`Failed for some unknown reason`);
    }
    console.log(`Finished job#${id} with status=${status}`);
    return { status };
  },
);

void emailQueue.start();

My use case is I'm running Next.js in a container and just want this to run in the background. So I just put the void emailQueue.start() so that it does it in the background. This strategy seems to work with pgboss

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions