From 62b4d85ef7946ba58490308a393de8e9f2afa41e Mon Sep 17 00:00:00 2001 From: nexxo Date: Sat, 25 Jul 2026 16:17:44 +0200 Subject: [PATCH] fix(admin): release notification claim on dispatch failure so retries aren't blocked Co-Authored-By: Claude Opus 4.8 --- app/Livewire/Admin/Maintenance.php | 18 +++++++++++++++--- 1 file changed, 15 insertions(+), 3 deletions(-) diff --git a/app/Livewire/Admin/Maintenance.php b/app/Livewire/Admin/Maintenance.php index be73703..14b4472 100644 --- a/app/Livewire/Admin/Maintenance.php +++ b/app/Livewire/Admin/Maintenance.php @@ -204,11 +204,23 @@ class Maintenance extends Component return; } + // Claim the row, then dispatch. If dispatch fails, release the claim + // immediately (delete if we created it, else restore the prior attempt + // time) so a resend can retry right away instead of waiting out the TTL. + $wasNew = $delivery->wasRecentlyCreated; + $priorUpdatedAt = $delivery->updated_at; $delivery->forceFill(['updated_at' => now()])->save(); $mail->notificationId = $delivery->id; - Mail::to($customer->email) - ->locale($customer->locale ?: config('app.locale')) - ->queue($mail); + + try { + Mail::to($customer->email) + ->locale($customer->locale ?: config('app.locale')) + ->queue($mail); + } catch (\Throwable $e) { + $wasNew ? $delivery->delete() : $delivery->forceFill(['updated_at' => $priorUpdatedAt])->save(); + + throw $e; + } } public function render()