Skip to main content
In certain workflows, you may need a parent job to fail immediately if any of its child jobs fail. The failParentOnFailure option allows you to achieve this behavior. When set to true on a child job, it ensures that if the child fails, its parent job is also marked as failed.

Key Behavior

Selective

Only children with failParentOnFailure: true will trigger parent failure

Recursive

Failure propagates up the hierarchy to grandparents and beyond

Immediate

Parent fails as soon as qualifying child fails

Lazy Marking

Parent is marked failed lazily when next processed

Basic Usage

Recursive Failure Propagation

The failure can cascade through multiple levels of the hierarchy:
As soon as a child with this option fails, the parent job will be marked as failed lazily. A worker must process the parent job before it transitions to the failed state. The failure will result in an UnrecoverableError with the message “child failed”.

How It Works

Understanding the failure propagation flow:
  1. grandchild-job-1 fails → Its parent (child-job) fails because failParentOnFailure: true
  2. child-job fails → Since it also has failParentOnFailure: true, the root-job fails
  3. grandchild-job-2 fails → child-job does NOT fail (no failParentOnFailure on grandchild-job-2)
  4. child-job-2 fails → root-job remains unaffected (no failParentOnFailure on child-job-2)
1

Child with failParentOnFailure fails

A child job with failParentOnFailure: true encounters an error and moves to failed state.
2

Parent is marked for failure

BullMQ marks the parent job to fail, but the transition happens lazily.
3

Worker processes parent

When a worker attempts to process the parent, it immediately fails with an UnrecoverableError.
4

Recursive validation

If the parent also has failParentOnFailure: true, the process repeats up the hierarchy.

Use Cases

When certain child jobs are critical to the workflow and their failure should abort the entire process:
Ensure payment workflows fail fast when critical validation steps fail:
Create data pipelines where quality checks must pass:

Error Handling

When a parent fails due to a child failure, you can handle it in the parent worker:

Combining with Other Options

failParentOnFailure takes precedence over other failure handling options like removeDependencyOnFailure and ignoreDependencyOnFailure. If a child has failParentOnFailure: true, the parent will fail regardless of other options.
You can combine different strategies for different children:

Monitoring Failed Parents

You can monitor and handle parent failures:

API Reference