taskforcesh / bullmq

BullMQ - Message Queue and Batch processing for NodeJS and Python based on Redis
https://bullmq.io
MIT License
5.89k stars 380 forks source link

Flows: job.getChildrenValues is not a function for sandboxed workers #753

Open bpinney opened 2 years ago

bpinney commented 2 years ago

Version 1.46.6 The below line works as documented for normal workers, but throws the error job.getChildrenValues is not a function for sandboxed processors.

const childrenValues = await job.getChildrenValues();

Below are code snippets used to test, sans imports for brevity. A nested job added to a FlowProducer:

await flowProducer.add({
    name: "parent-job",
    queueName: "parent",
    children: [{
      name: "child",
      queueName: "child",
      data: { colour: "red" },
    }]
  });

Processed by sandboxed worker processes:

const parentWorker = new Worker(
  "parent", 
  path.join(__dirname, "../dist") + "/processor-parent.js",
);

const childWorker = new Worker(
  "child", 
  path.join(__dirname, "../dist") + "/processor-child.js",
);

Processor definitions:

import { processorParent } from "./processors";
export default processorParent;

import { processorChild } from "./processors";
export default processorChild;

processors.ts:

export const processorParent = async(job: Job) => {
  const childrenValues = await job.getChildrenValues();
  console.log(childrenValues);
}

export const processorChild = async (job: Job) => {
  return "Child Return Test Value"
}
manast commented 2 years ago

Yes, we are missing some proxies for flow related methods in Flows. Thanks for reporting.

AlexOwl commented 2 years ago

Current workout:

import { Job, Queue } from "bullmq"

export default async function(sandboxedJob) {
    const queue = new Queue(sandboxedJob.queueName, { connection }) // pass the same connection settings
    const job = await Job.fromId(queue, sandboxedJob.id)

    const childrenValues = await job.getChildrenValues()
}
fmoessle commented 1 year ago

Any updates on this?

imperfect-circuits commented 1 year ago

I am also looking for this to be resolved.

oxypomme commented 11 months ago

+1

shaunakv1 commented 1 month ago

An updates on this?

tolgap commented 2 weeks ago

I just got bit by this thinking it was supported. Rewrote a large chunk of my app and ran into this issue. I should've checked it first with a small example 😞.

manast commented 1 week ago

We have a PR for this, seems like it could be merged anytime now https://github.com/taskforcesh/bullmq/pull/1417