From 925cba58402a16e465da603407d2ec4ae65486b6 Mon Sep 17 00:00:00 2001 From: Roger Karlsen Date: Wed, 18 Mar 2026 14:33:30 +0100 Subject: [PATCH] Fix alarm exception caused by constructor consuming alarm before runtime delivery --- packages/alarms/src/index.ts | 10 +++++----- 1 file changed, 5 insertions(+), 5 deletions(-) diff --git a/packages/alarms/src/index.ts b/packages/alarms/src/index.ts index 852b1ec..b18c8ef 100644 --- a/packages/alarms/src/index.ts +++ b/packages/alarms/src/index.ts @@ -85,8 +85,8 @@ export class Alarms

> { } } - // Execute any pending alarms and schedule the next alarm - await this.alarm(); + // Don't execute callbacks; the runtime delivers the alarm after init. + await this._scheduleNextAlarm(); }); }); } @@ -268,9 +268,9 @@ export class Alarms

> { private async _scheduleNextAlarm() { // Find the next schedule that needs to be executed const result = this.sql` - SELECT time, COALESCE(identifier, 'default') as identifier FROM _actor_alarms + SELECT time, COALESCE(identifier, 'default') as identifier FROM _actor_alarms WHERE time > ${Math.floor(Date.now() / 1000)} - ORDER BY time ASC + ORDER BY time ASC LIMIT 1 `; if (!result || !this.storage) return; @@ -318,7 +318,7 @@ export class Alarms

> { // Update next execution time for cron schedules const nextExecutionTime = getNextCronTime(row.cron); const nextTimestamp = Math.floor(nextExecutionTime.getTime() / 1000); - + this.sql` UPDATE _actor_alarms SET time = ${nextTimestamp} WHERE id = ${row.id} `;