diff --git a/docs/gitbook/guide/jobs/stalled.md b/docs/gitbook/guide/jobs/stalled.md index bc02ca0539..2c2922a45d 100644 --- a/docs/gitbook/guide/jobs/stalled.md +++ b/docs/gitbook/guide/jobs/stalled.md @@ -1,12 +1,7 @@ # Stalled -{% hint style="info" %} -Stalled jobs checks will only work if there is at least one [`QueueScheduler`](../queuescheduler.md) instance configured in the Queue. -{% endhint %} - {% hint style="danger" %} -From BullMQ 2.0 and onwards, the QueueScheduler is not needed anymore. -For manually fetching jobs check this [pattern](https://docs.bullmq.io/patterns/manually-fetching-jobs#checking-for-stalled-jobs) +From BullMQ 2.0 and onwards, the QueueScheduler is not needed anymore. For manually fetching jobs check this [pattern](https://docs.bullmq.io/patterns/manually-fetching-jobs#checking-for-stalled-jobs) {% endhint %} When a job is in an active state, i.e., it is being processed by a worker, it needs to continuously update the queue to notify that the worker is still working on the job. This mechanism prevents a worker that crashes or enters an endless loop from keeping a job in an active state forever. @@ -17,9 +12,11 @@ When a worker is not able to notify the queue that it is still working on a give There is not a 'stalled' state, only a 'stalled' event emitted when a job is automatically moved from active to waiting state. {% endhint %} +If a job stalls more than a predefined limit (see the maxStalledCount option [https://api.docs.bullmq.io/interfaces/v4.WorkerOptions.html#maxStalledCount](https://api.docs.bullmq.io/interfaces/v4.WorkerOptions.html#maxStalledCount)), the job will be failed permanently with the error "_job stalled more than allowable limit_". The default is 1, as stalled jobs should be a rare occurrence, but you can increase this number if needed. + In order to avoid stalled jobs, make sure that your worker does not keep Node.js event loop too busy, the default max stalled check duration is 30 seconds, so as long as you do not perform CPU operations exceeding that value you should not get stalled jobs. -Another way to reduce the chance for stalled jobs is using so called "sandboxed" processors. In this case, the workers will spawn new separate Node.js processes, running separately from the main process. +Another way to reduce the chance of stalled jobs is using so-called "sandboxed" processors. In this case, the workers will spawn new separate Node.js processes, running separately from the main process. {% code title="main.ts" %} ```typescript