Skip to content
Draft
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
4 changes: 3 additions & 1 deletion src/Illuminate/Queue/Events/JobReleasedAfterException.php
Original file line number Diff line number Diff line change
Expand Up @@ -10,11 +10,13 @@ class JobReleasedAfterException
* @param string $connectionName The connection name.
* @param \Illuminate\Contracts\Queue\Job $job The job instance.
* @param int|null $backoff The backoff delay.
* @param \Throwable|null $exception The exception that caused the job to be released.
*/
public function __construct(
public $connectionName,
public $job,
public $backoff = null
public $backoff = null,
public $exception = null,
) {
}
}
2 changes: 1 addition & 1 deletion src/Illuminate/Queue/Worker.php
Original file line number Diff line number Diff line change
Expand Up @@ -614,7 +614,7 @@ protected function handleJobException($connectionName, $job, WorkerOptions $opti
$job->release($backoff);

$this->events->dispatch(new JobReleasedAfterException(
$connectionName, $job, $backoff
$connectionName, $job, $backoff, $e
));
}
}
Expand Down
5 changes: 3 additions & 2 deletions tests/Queue/QueueWorkerTest.php
Original file line number Diff line number Diff line change
Expand Up @@ -624,11 +624,12 @@ public function testJobReleasedEvent()
$worker = $this->getWorker('default', ['queue' => [$job]]);
$worker->runNextJob('default', 'queue', $this->workerOptions(['backoff' => 10]));

$this->events->shouldHaveReceived('dispatch')->with(m::on(function ($event) use ($job) {
$this->events->shouldHaveReceived('dispatch')->with(m::on(function ($event) use ($job, $e) {
return $event instanceof JobReleasedAfterException
&& $event->connectionName === 'default'
&& $event->job === $job
&& $event->backoff === 10;
&& $event->backoff === 10
&& $event->exception === $e;
}))->once();
}

Expand Down
Loading