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

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

Open
bpinney opened this issue Sep 15, 2021 · 9 comments · May be fixed by #1417 or #2600
Open

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

bpinney opened this issue Sep 15, 2021 · 9 comments · May be fixed by #1417 or #2600
Labels
enhancement New feature or request

Comments

@bpinney
Copy link

bpinney commented Sep 15, 2021

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"
}
@bpinney bpinney changed the title job.getChildrenValues is not a function for sandboxed workers Flows: job.getChildrenValues is not a function for sandboxed workers Sep 15, 2021
@manast manast added the enhancement New feature or request label Sep 16, 2021
@manast
Copy link
Contributor

manast commented Sep 16, 2021

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

@AlexOwl
Copy link
Contributor

AlexOwl commented Aug 15, 2022

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
Copy link
Contributor

Any updates on this?

@imperfect-circuits
Copy link
Contributor

I am also looking for this to be resolved.

@oxypomme
Copy link

+1

anirudh1713 added a commit to anirudh1713/bullmq that referenced this issue Jun 9, 2024
right before starting a child, get and pass children values along side other job data. This should
be okay as the parent job runs only after all children have finished. We then use this data to
implement `getChildrenValues` function for sanboxed jobs.

"fix  taskforcesh#1306", "fix taskforcesh#753".
@anirudh1713 anirudh1713 linked a pull request Jun 9, 2024 that will close this issue
@shaunakv1
Copy link

An updates on this?

@tolgap
Copy link

tolgap commented Aug 24, 2024

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
Copy link
Contributor

manast commented Aug 26, 2024

We have a PR for this, seems like it could be merged anytime now #1417

@alimoezzi
Copy link

An update on this?

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
enhancement New feature or request
Projects
None yet
9 participants