yiisoft / yiisoft/yii2-queue

How to make repeated attempts with progressive delay?

Open
#143 25 comments 20 reactions 0 assignees View on GitHub

Nobody has claimed this yet.

help wanted severity:BC breaking status:ready for adoption type:enhancement
Dominant language
PHP
Stars
1.1k
Forks
285
Avg merge
5d 3h
Merged PRs (30d)
2

Description

I want to make each retry attempt each time more delayed. However, I could not do it, because there is no delay property in ErrorEvent:

Yii::$app->queue->on(Queue::EVENT_AFTER_ERROR, function (ErrorEvent $event) {
    if ($event->job instanceof SomeJob) {
        //$event->delay = $event->attempt * 30; // there I want to set delay based on attempt
        $event->retry = $event->attempt < 5;
    }
});

It would also be nice to add in the RetryableJob method getRetryDelay:

public function getRetryDelay($attempt, $error)
{
    return $attempt * 30;
}

Contributor guide

Open the contributing guide

First steps

  1. Read the whole issue, then the project's contributing guide.
  2. Comment on the issue to say you are picking it up — it saves two people doing the same work.
  3. Fork the repository and make your change on a branch.
  4. Open a pull request that references the issue number.

Research direction

Start by tracing ErrorEvent handling and the RetryableJob retry flow to see where retry timing is selected and how queue backends apply it. Define how a getRetryDelay($attempt, $error) hook or event delay should interact with the existing retry flag, then verify that repeated attempts can use increasing delays without changing current retry behavior.

Written by the indexing model from the issue text.

Assessment

Tech stack
php
Domain
backend
Issue type
Feature
Difficulty
4/5
Estimated time
3-5 days
Activity status
Stale
Clarity
Mostly clear
Newbie friendliness
35/100

Get new issues in your inbox

A short digest of beginner-friendly GitHub issues.