Skip to content

Commit 1deaa36

Browse files
12.x scheduled task failed not dispatched on scheduled task failing (#55572)
* Enhance ScheduleRunCommand to dispatch failure events and add integration test - Updated `ScheduleRunCommand` to dispatch `ScheduledTaskFailed` event when a scheduled command fails. - Added handling for exit codes to improve error reporting. - Introduced `ScheduleRunCommandTest` to verify that failure events are dispatched correctly for failing scheduled tasks. * Enhance ScheduleRunCommand to dispatch failure events and add integration test - Updated `ScheduleRunCommand` to dispatch `ScheduledTaskFailed` event when a scheduled command fails. - Added handling for exit codes to improve error reporting. - Introduced `ScheduleRunCommandTest` to verify that failure events are dispatched correctly for failing scheduled tasks. * Enhance ScheduleRunCommand to dispatch failure events and add integration test - Updated `ScheduleRunCommand` to dispatch `ScheduledTaskFailed` event when a scheduled command fails. - Added handling for exit codes to improve error reporting. - Introduced `ScheduleRunCommandTest` to verify that failure events are dispatched correctly for failing scheduled tasks. * remove the test class as it's not consistent due to the event scheduling testing complication * remove the test class as it's not consistent due to the event scheduling testing complication * formatting --------- Co-authored-by: Taylor Otwell <[email protected]>
1 parent d74311d commit 1deaa36

File tree

1 file changed

+5
-0
lines changed

1 file changed

+5
-0
lines changed

src/Illuminate/Console/Scheduling/ScheduleRunCommand.php

+5
Original file line numberDiff line numberDiff line change
@@ -2,6 +2,7 @@
22

33
namespace Illuminate\Console\Scheduling;
44

5+
use Exception;
56
use Illuminate\Console\Application;
67
use Illuminate\Console\Command;
78
use Illuminate\Console\Events\ScheduledTaskFailed;
@@ -196,6 +197,10 @@ protected function runEvent($event)
196197
round(microtime(true) - $start, 2)
197198
));
198199

200+
if ($event->exitCode !== 0) {
201+
throw new Exception("Scheduled command [{$event->command}] failed with exit code [{$event->exitCode}].");
202+
}
203+
199204
$this->eventsRan = true;
200205
} catch (Throwable $e) {
201206
$this->dispatcher->dispatch(new ScheduledTaskFailed($event, $e));

0 commit comments

Comments
 (0)