Skip to content

Change #528 breaks existing canRetry logic and interface contracts #549

Description

@jeffreyzant

Description

Invoking the canRetry method with a null $error argument value which is introduced in #528 is a major issue and can break existing implementations of canRetry. The definition of RetryableJobInterface clearly states:

* @param int $attempt The attempt number 
* @param \Exception|\Throwable $error The error from the last execution of the job

In our jobs, we rely on the error instance to determine whether a job should be retried. Calling canRetry with a null error value and ignoring the job's failure has already led to significant data loss.

Example of an existing implementation that depends on the error:

/**
 * Defines if the job can be retryed automatically.
 */
public function canRetry($attempt, $error): bool
{
    if ($error instanceof SpecificException) {
        if ($attempt < 12) {
            return true;
        }
    }

    return false;
}

The change alters the contract of the interface in a backward-incompatible way and undermines the intended retry logic.

Package version

2.3.8

PHP version

8.4.15

Metadata

Metadata

Assignees

No one assigned

    Labels

    Type

    No type
    No fields configured for issues without a type.

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions