Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Forget job timer in case of exception or failed job #1127

Merged
merged 2 commits into from
Feb 22, 2022
Merged

Forget job timer in case of exception or failed job #1127

merged 2 commits into from
Feb 22, 2022

Conversation

Namoshek
Copy link
Contributor

This PR fixes the remaining cases not handled by 69486d5.

I wasn't sure if having two event listeners doing the exact same thing would be preferred over a single listener supporting both events.


Currently, jobs throwing an exception and jobs which fail (e.g. using $this->fail()) still leak the job timer:

[2022-02-21 20:13:27] local.DEBUG: The first job is run.
[2022-02-21 20:13:27] local.DEBUG: Stopwatch {"timers":0}
[2022-02-21 20:13:27] local.DEBUG: The first job is run.
[2022-02-21 20:13:27] local.DEBUG: Stopwatch {"timers":0}
[2022-02-21 20:13:30] local.DEBUG: The first job is run.
[2022-02-21 20:13:30] local.DEBUG: Stopwatch {"timers":0}
[2022-02-21 20:13:30] local.DEBUG: The second job is started.
[2022-02-21 20:13:30] local.DEBUG: The third job throws an exception.
[2022-02-21 20:13:30] local.ERROR: Oh no! {"exception":"[object] (Exception(code: 0): Oh no! at /home/marvin/projects/laravel-horizon-memory-leak/app/Jobs/ThirdJob.php:22)"}
[2022-02-21 20:13:30] local.DEBUG: The second job is started.
[2022-02-21 20:13:30] local.DEBUG: The third job throws an exception.
[2022-02-21 20:13:30] local.ERROR: Oh no! {"exception":"[object] (Exception(code: 0): Oh no! at /home/marvin/projects/laravel-horizon-memory-leak/app/Jobs/ThirdJob.php:22)"}
[2022-02-21 20:13:33] local.DEBUG: The first job is run.
[2022-02-21 20:13:33] local.DEBUG: Stopwatch {"timers":2}
[2022-02-21 20:13:33] local.DEBUG: The second job is started.
[2022-02-21 20:13:33] local.DEBUG: The third job throws an exception.
[2022-02-21 20:13:33] local.ERROR: Oh no! {"exception":"[object] (Exception(code: 0): Oh no! at /home/marvin/projects/laravel-horizon-memory-leak/app/Jobs/ThirdJob.php:22)"}
[2022-02-21 20:13:33] local.DEBUG: The first job is run.
[2022-02-21 20:13:33] local.DEBUG: Stopwatch {"timers":3}

@taylorotwell taylorotwell merged commit 2c2c28d into laravel:5.x Feb 22, 2022
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

2 participants