Repository navigation
fix(engine): keep flushing buffered events after one fails - #48
Merged
Merged
Conversation
ScheduleEngine::flush() emptied its buffer, then stopped at the first event that threw: every event after it was dropped, on each request. Each event is now tried, and the failures are thrown together as a ScheduleException.
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.
Problem
ScheduleEngine::flush()hands the drivers what was scheduled before they could store it (with Action Scheduler, onaction_scheduler_init). It emptied the buffer, then looped with no boundary: the first event that threw dropped every event after it. Events are declared again in the same order on every request, so those later events were never scheduled as long as the failing one stayed.Reproduced with the real
ActionSchedulerDriveragainst the test fake: three buffered events, the second with a recurrence WordPress does not know. Onmainonly the first one is stored.State was otherwise fine: the buffer is emptied before the loop and
busyis restored bygive().Change
Every event is tried. The failures are then thrown together as one
ScheduleExceptionnaming the hooks, with the first failure asprevious. The failure therefore still surfaces, as before; it is not swallowed. A non-ScheduleExceptionraised by a driver now comes out wrapped. A failed event is not kept in the buffer. No public API change.Not changed
The exception still leaves the
action_scheduler_initcallback, as it did. Whether it should be reported without interrupting the request needs a reporting channel on the engine, which is new public API.Checks
composer qa:fastandcomposer qapass locally; Semgrep is not installed locally and line coverage and mutation score were not measured locally (CI covers them).