How to make repeated attempts with progressive delay?
Open
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
First steps
- Read the whole issue, then the project's contributing guide.
- Comment on the issue to say you are picking it up — it saves two people doing the same work.
- Fork the repository and make your change on a branch.
- 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