[7.x] Catch and report exceptions thrown during schedule run execution #32461
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.
As the task scheduler executes scheduled events sequentially, if any of the tasks were to raise a
Throwable
, any subsequent tasks in that execution thread will not be processed.Consider the following task schedule:
Whilst your error reporting tool or logging channel would likely report this occurrence, none of the tasks subsequent to the
Throwable
would be run at all, which is undesirable.In order to allow task execution to continue to flow, whilst also reporting the exception to your error reporting tool or logging channel, catching and reporting the
Throwable
will be sufficient to allow the remaining tasks to execute.I've also moved the dispatch of the
ScheduledTaskFinished
event and setting ofeventsRan
inside thetry
block, as aThrowable
being raised indicates that the task did not finish running, and as such should not be flagged as having been run.