Skip to content

Delete all alarms on abortAllDurableObjects()#1918

Merged
anonrig merged 4 commits intomainfrom
bcoll/abort-all-durable-object-alarms
Mar 2, 2026
Merged

Delete all alarms on abortAllDurableObjects()#1918
anonrig merged 4 commits intomainfrom
bcoll/abort-all-durable-object-alarms

Conversation

@mrbbot
Copy link
Contributor

@mrbbot mrbbot commented Mar 28, 2024

Fixes cloudflare/workers-sdk#5388

In the Workers Vitest integration, we call the abortAllDurableObjects() function after each test to abort all Durable Objects and close all SQLite databases. If the isolated storage option is enabled, we backup/restore .sqlite files to automatically undo writes performed in tests. Right now, this doesn't cancel Durable Object alarms. This means that an alarm scheduled in one test might end up firing when another later test is running. This could lead to unexpected test results, and non-determinism in tests.

This PR addresses this issue by automatically deleting all Durable Object alarms when abortAllDurableObjects() is called. This is a local-only internal API that's currently only used in the Vitest integration, so making this breaking change is fine. 👍

@mrbbot mrbbot requested review from a team as code owners March 28, 2024 12:59
@mrbbot mrbbot requested review from byule and harrishancock March 28, 2024 12:59
@allan-simon
Copy link

allan-simon commented Jan 20, 2026

is there a reason why this PR was not merged, it would help solve the known issue of vitest integration ?

If necessary I can reopen a similar PR rebased on latest master if @mrbbot has not the time ?

@avenceslau avenceslau force-pushed the bcoll/abort-all-durable-object-alarms branch from 4858383 to 114b466 Compare February 5, 2026 14:53
@avenceslau avenceslau requested a review from a team as a code owner February 5, 2026 17:30
@avenceslau avenceslau force-pushed the bcoll/abort-all-durable-object-alarms branch from 21f19cb to cf82243 Compare March 1, 2026 22:26
@avenceslau avenceslau force-pushed the bcoll/abort-all-durable-object-alarms branch from cf82243 to 0aa0611 Compare March 1, 2026 22:33
@codspeed-hq
Copy link

codspeed-hq bot commented Mar 1, 2026

Merging this PR will improve performance by 26.77%

⚡ 1 improved benchmark
✅ 69 untouched benchmarks
⏩ 129 skipped benchmarks1

Performance Changes

Benchmark BASE HEAD Efficiency
bodyWithHeaders[Response] 38.2 µs 30.1 µs +26.77%

Comparing bcoll/abort-all-durable-object-alarms (4aa850a) with main (cce9f17)

Open in CodSpeed

Footnotes

  1. 129 benchmarks were skipped, so the baseline results were used instead. If they were deleted from the codebase, click here and archive them to remove them from the performance reports.

@anonrig anonrig merged commit 94d692a into main Mar 2, 2026
22 checks passed
@anonrig anonrig deleted the bcoll/abort-all-durable-object-alarms branch March 2, 2026 15:18
emily-shen added a commit to cloudflare/cloudflare-docs that referenced this pull request Mar 2, 2026
Removed section on Durable Object alarms from known issues.

cloudflare/workerd#1918
@kentonv
Copy link
Member

kentonv commented Mar 18, 2026

Ironically, a week after this PR was merged, vitest-pool-workers actually removed its usage of this API. After two years of waiting...

And after some discussion, we feel that it doesn't make sense for abortAllDurableObjects() to cancel alarms. Cancelling alarms is essentially deleting data from the DOs, but since it doesn't delete all data, it leaves them in an inconsistent state.

It could make sense to add a new deleteAllDurableObjects() API which aborts DOs, cancels alarms, and deletes underlying data, but that should be a separate API.

In any case I will be rolling this back as it is blocking #6104.

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.

Reset Durable Object alarms between tests

6 participants