Skip to content

Commit 947440e

Browse files
committed
Switch to file-based lock for email cooldown in ListenerPanoptesPusherCommand to ensure persistence across cache flushes and restarts.
1 parent 1d96960 commit 947440e

1 file changed

Lines changed: 11 additions & 5 deletions

File tree

app/Console/Commands/ListenerPanoptesPusherCommand.php

Lines changed: 11 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -403,12 +403,18 @@ private function sendErrorEmail(string $message, ?\Throwable $e, array $context,
403403
return;
404404
}
405405

406-
// MASTER GATEKEEPER - Strictly 1 hour cooldown across all error types
407-
$lockKey = 'panoptes_listener_global_email_cooldown';
408-
if (Cache::has($lockKey)) {
409-
return;
406+
// PHYSICAL FILE LOCK GATEKEEPER - Survives Cache::flush() and process restarts
407+
$lockFile = storage_path('framework/panoptes_pusher_email.lock');
408+
409+
if (file_exists($lockFile)) {
410+
$lastSent = (int) file_get_contents($lockFile);
411+
if ((time() - $lastSent) < 3600) {
412+
return; // Less than an hour ago
413+
}
410414
}
411-
Cache::put($lockKey, true, 3600);
415+
416+
// Record current time in lock file
417+
file_put_contents($lockFile, time());
412418

413419
try {
414420
$subject = ($isCritical ? '[CRITICAL] ' : '[ERROR] ').'Panoptes Listener - '.config('app.name');

0 commit comments

Comments
 (0)