Repository navigation
[13.x] Add Queue::whenJobRunsLongerThan - #62141
Merged
Merged
Conversation
|
Thanks for submitting a PR! Note that draft PRs are not reviewed. If you would like a review, please mark your pull request as ready for review in the GitHub user interface. Pull requests that are abandoned in draft may be closed due to inactivity. |
jackbayliss
marked this pull request as ready for review
October 27, 2026 14:50
albertcht
pushed a commit
to hypervel/docs
that referenced
this pull request
Nov 3, 2026
Applications had no direct way to react when a queued job attempt takes too long. QueueManager::whenJobRunsLongerThan() registers a JobAttempted listener that calls the handler with the job and its duration in milliseconds when the attempt exceeds the threshold. The threshold accepts a date, CarbonInterval or number, like Connection::whenQueryingForLongerThan(). Ports laravel/framework#62141 from 13.x at b20bf7f442. The method is natively typed and carries a Boot-only warning like the other listener registrars. Upstream has no docs, so the Job Events section of queues.md now describes it. Tests: ported QueueManagerTest::testWhenJobRunsLongerThan. tests/Queue passes; composer analyse is clean.
albertcht
pushed a commit
to hypervel/queue
that referenced
this pull request
Nov 3, 2026
Applications had no direct way to react when a queued job attempt takes too long. QueueManager::whenJobRunsLongerThan() registers a JobAttempted listener that calls the handler with the job and its duration in milliseconds when the attempt exceeds the threshold. The threshold accepts a date, CarbonInterval or number, like Connection::whenQueryingForLongerThan(). Ports laravel/framework#62141 from 13.x at b20bf7f442. The method is natively typed and carries a Boot-only warning like the other listener registrars. Upstream has no docs, so the Job Events section of queues.md now describes it. Tests: ported QueueManagerTest::testWhenJobRunsLongerThan. tests/Queue passes; composer analyse is clean.
binaryfire
added a commit
to hypervel/components-backup
that referenced
this pull request
Nov 3, 2026
Applications had no direct way to react when a queued job attempt takes too long. QueueManager::whenJobRunsLongerThan() registers a JobAttempted listener that calls the handler with the job and its duration in milliseconds when the attempt exceeds the threshold. The threshold accepts a date, CarbonInterval or number, like Connection::whenQueryingForLongerThan(). Ports laravel/framework#62141 from 13.x at b20bf7f442. The method is natively typed and carries a Boot-only warning like the other listener registrars. Upstream has no docs, so the Job Events section of queues.md now describes it. Tests: ported QueueManagerTest::testWhenJobRunsLongerThan. tests/Queue passes; composer analyse is clean.
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
Laravel offers
whenQueryingForLongerThan,whenRequestLifecycleIsLongerThanas well aswhenCommandLifecycleIsLongerThan, but there's nothing equivalent for queued jobs.This PR adds
Queue::whenJobRunsLongerThan:My thought here is I wanna know when, which job, and how long it ran for - over a certain amount of time (90 seconds), so I know they should be moved to a Pro worker.
More generally, it's useful for spotting jobs that are creeping toward their timeout, a hosting platform's runtime limit etc.
Only downside I guess is we can just listen to
JobAttemptedmanually / macro it, but you have to know about it, so by putting it on the manager its on the facade soooo the people can see it via intelephense and its similar to the other methods.I also guess most people would try to use
Queue::after()but that doesn't handle failed jobs.So, givin this one a go feel free to throw away if you aint feelin the vibe