Skip to content

feat(schedule): pass the rejected row to the error handler - #296

Merged
ChiragAgg5k merged 1 commit into
mainfrom
feat/schedule-onerror-row
Sep 17, 2026
Merged

ChiragAgg5k merged 1 commit into
mainfrom
feat/schedule-onerror-row

Conversation

@ChiragAgg5k

Copy link
Copy Markdown
Member

What

onError received the throwable and nothing else. It now also receives the Row that make() refused, so a handler can say which schedule failed.

($this->onError)($error, $row);

Backward compatible: PHP ignores extra positional arguments to userland closures, so a handler declaring only \Throwable $error keeps working. ReconcileTest still has one of those and still passes.

$row is null for a failure no single row owns (a snapshot that throws).

Why

On Appwrite Cloud these arrive as Sentry events reading Collection not found, with region = fra and nothing else — for one of several thousand schedules. Identifying the row meant writing a task to re-derive it.

The identity is already in scope at the catch site; it just wasn't passed on. With this, a handler can do what the enqueue path in the same file already does:

Span::init('schedule.functions.enqueue');
Span::add('project.id', ...);
Span::add('schedule.id', ...);

Tests

One case: the handler is given the row make() rejected, asserted on its id and data. Seen red — it errors without the src/ change.

bin/monorepo check schedule, bin/monorepo test schedule (96 unit + 9 e2e) and bin/monorepo validate pass.

Note

Touches the same catch block as #295, so whichever lands second needs a one-line rebase.

An onError handler was given the throwable and nothing else, so a failure
it could name -- the row `make` refused -- arrived without one. In Appwrite
Cloud that is a Sentry event reading "Collection not found", region and
nothing more, for one of thousands of schedules.

The row is already in scope at the catch site. Passing it on lets a handler
attach the schedule's identity to whatever it reports. Handlers that declare
only the error keep working, since PHP ignores the extra argument.
@github-actions

Copy link
Copy Markdown

Benchmark results

schedule — dispatch and reconcile at scale (4 cores, 10000 schedules: 30% cron / 70% interval, 30 ticks)

stage scale p50 ms max ms
reconcile: full snapshot, cold (every row made) 10000 rows 59.51 59.51
reconcile: full snapshot, warm (version diff) 10000 rows 1.52 5.40
tick + commit (one minute of coverage) 10000 schedules 48.98 63.78
cron next occurrence: leap-day expression 1000 windows 138.20 138.20

115680 occurrences dispatched, 3856 per tick average. Selecting one minute of coverage spends 0.082% of the 60s tick interval.

Shared CI runners — treat absolute numbers as rough, compare modes within a run. Commit d96a9af.

@ChiragAgg5k
ChiragAgg5k merged commit 95794fb into main Sep 17, 2026
5 checks passed
@ChiragAgg5k
ChiragAgg5k deleted the feat/schedule-onerror-row branch September 17, 2026 15:41
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