Skip to content

Fix alarm exception caused by constructor consuming alarm before runtime delivery#114

Open
haggbart wants to merge 1 commit into
cloudflare:mainfrom
haggbart:fix/alarm-double-execution-on-wake
Open

Fix alarm exception caused by constructor consuming alarm before runtime delivery#114
haggbart wants to merge 1 commit into
cloudflare:mainfrom
haggbart:fix/alarm-double-execution-on-wake

Conversation

@haggbart
Copy link
Copy Markdown

The Alarms constructor calls await this.alarm() inside blockConcurrencyWhile, consuming due alarm rows during init. The runtime then tries to deliver the same alarm after init and marks it as outcome: "exception".

Replace await this.alarm() with await this._scheduleNextAlarm(). Only register the next alarm time during init, let the runtime handle execution.

Tested by deploying a worker with @Persist fields and this.alarms.schedule() in the callback. Before fix: intermittent exceptions on every alarm cycle, @Persist state resetting due to double-execution. After fix: no exceptions, state persisting correctly.

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