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 failureRecursive
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:- grandchild-job-1 fails → Its parent (child-job) fails because
failParentOnFailure: true - child-job fails → Since it also has
failParentOnFailure: true, the root-job fails - grandchild-job-2 fails → child-job does NOT fail (no
failParentOnFailureon grandchild-job-2) - child-job-2 fails → root-job remains unaffected (no
failParentOnFailureon 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
Critical Path Dependencies
Critical Path Dependencies
When certain child jobs are critical to the workflow and their failure should abort the entire process:
Payment Processing
Payment Processing
Ensure payment workflows fail fast when critical validation steps fail:
Data Pipeline with Quality Gates
Data Pipeline with Quality Gates
Create data pipelines where quality checks must pass:
