Skip to main content
In some situations, you need to get a job and all of its children, grandchildren, and so on. The getFlow method allows you to retrieve the entire job hierarchy.

Using getFlow

The pattern to solve this requirement consists of using the getFlow method:
Each child may have a job property and, if they have children as well, they would have the children property.

NodeOpts Interface

The getFlow method accepts a NodeOpts interface with the following properties:

JobNode Structure

The method returns a JobNode structure:

Limiting Results

You may need to limit the information retrieved if you have many children for one of the job nodes:

Parameters

depth
number
default:"10"
Maximum depth or levels to visit in the tree. Controls how deep the hierarchy traversal goes.
maxChildren
number
default:"20"
Maximum quantity of children per type (processed, unprocessed, failed, ignored) to retrieve for each node.
id
string
required
The ID of the root job to start the tree traversal from.
queueName
string
required
The queue name where the root job is located.
prefix
string
default:"bull"
The prefix used for the job keys in Redis.

Example Use Cases

Retrieve the entire flow tree to monitor the progress of a complex workflow:
Get the complete flow tree to identify which jobs failed:
Use depth and maxChildren to paginate through large job hierarchies:

Performance Considerations

Retrieving large flow trees can be resource-intensive. Use the depth and maxChildren parameters to limit the amount of data retrieved.
For very large flows, consider implementing pagination by retrieving the tree in chunks using the depth parameter.

API Reference