Skip to content

fix(engine): keep flushing buffered events after one fails - #48

Merged
ogorzalka merged 1 commit into
mainfrom
fix/flush-keeps-going
Dec 3, 2026
Merged

ogorzalka merged 1 commit into
mainfrom
fix/flush-keeps-going

Conversation

@ogorzalka

Copy link
Copy Markdown
Member

Problem

ScheduleEngine::flush() hands the drivers what was scheduled before they could store it (with Action Scheduler, on action_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 ActionSchedulerDriver against the test fake: three buffered events, the second with a recurrence WordPress does not know. On main only the first one is stored.

State was otherwise fine: the buffer is emptied before the loop and busy is restored by give().

Change

Every event is tried. The failures are then thrown together as one ScheduleException naming the hooks, with the first failure as previous. The failure therefore still surfaces, as before; it is not swallowed. A non-ScheduleException raised 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_init callback, 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:fast and composer qa pass locally; Semgrep is not installed locally and line coverage and mutation score were not measured locally (CI covers them).

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.
@ogorzalka
ogorzalka merged commit 77d9534 into main Dec 3, 2026
18 checks passed
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.

1 participant