Skip to content

Avoid destroying in-memory alarm tasks while running - #7215

Open
xThreeh wants to merge 1 commit into
cloudflare:mainfrom
xThreeh:fix-inmemory-alarm-self-destruction
Open

Avoid destroying in-memory alarm tasks while running#7215
xThreeh wants to merge 1 commit into
cloudflare:mainfrom
xThreeh:fix-inmemory-alarm-self-destruction

Conversation

@xThreeh

@xThreeh xThreeh commented Sep 2, 2026

Copy link
Copy Markdown

When an in-memory Durable Object alarm completes, cleanup can clear the preview task while its callback is still running. That destroys the active promise callback and aborts workerd with Promise callback destroyed itself. Defer the task cleanup to the next event-loop turn instead. Added a regression test covering an empty alarm handler with in-memory storage. Tests: bazel test //src/workerd/api/tests:actor-alarms-in-memory-test@; bazel test //src/workerd/api/tests:actor-alarms-test@; python tools/cross/format.py --check git. Fixes #7190

@xThreeh
xThreeh requested review from a team as code owners September 2, 2026 02:20
@github-actions

github-actions Bot commented Sep 2, 2026

Copy link
Copy Markdown

All contributors have signed the CLA ✍️ ✅
Posted by the CLA Assistant Lite bot.

@xThreeh

xThreeh commented Sep 2, 2026

Copy link
Copy Markdown
Author

I have read the CLA Document and I hereby sign the CLA

github-actions Bot added a commit that referenced this pull request Sep 2, 2026

@JosephDoUrden JosephDoUrden left a comment

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Pulled a4d2c98, in-memory test passes, same abort on cd90354 without the fix, alarm and name tests green.

updateAlarmInMemory has two branches and this only fixes the none one. worker.c++:4261 still assigns retry() straight into maybeAlarmPreviewTask. Call setAlarm inside alarm() on inMemory and it lands there, same abort at kj/async.c++:2187.

Second thing, the evalLater result is stored and never awaited, so it never runs. Deleted alarm still fires its timer, actor-cache.c++:183 alarm handler canceled shows on your branch, not base.

@xThreeh can you cover the reschedule branch too, and hand the old task to a task set that runs it, like #6934 did.

Fixes the reported case, not mergeable until the reschedule branch is covered.

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.

Bug: Durable Object alarm firing under durableObjectStorage = (inMemory = void) crashes the workerd process

2 participants