Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Reset Durable Object alarms between tests #5388

Open
mrbbot opened this issue Mar 26, 2024 · 0 comments · May be fixed by cloudflare/workerd#1918
Open

Reset Durable Object alarms between tests #5388

mrbbot opened this issue Mar 26, 2024 · 0 comments · May be fixed by cloudflare/workerd#1918
Assignees
Labels
vitest:priority vitest Relating to the Workers Vitest integration

Comments

@mrbbot
Copy link
Contributor

mrbbot commented Mar 26, 2024

Currently, Durable Object alarms are not reset between test runs and do not respect isolated storage. You must delete or run all alarms with runDurableObjectAlarm() scheduled in each test before finishing the test, to ensure rouge alarms don't fire later.

To fix this, we should probably cancel all alarms in the abortAllDurableObjects() function:

https://github.com/cloudflare/workerd/blob/9651cc9b814b20d4674f1b0cba2e83ebbfbc8c38/src/workerd/api/unsafe.c%2B%2B#L102-L107

This function is called before/after each test when isolatedStorage is enabled, which is when we'd like all alarms to be cancelled. As far as I know, locally workerd uses an in-memory alarm scheduler, so it should be possible to clear these without needing to write to storage.

See https://github.com/cloudflare/workerd/blob/9651cc9b814b20d4674f1b0cba2e83ebbfbc8c38/src/workerd/server/server.c%2B%2B#L2534-L2551 for the workerd implementation of the abort all function.

@mrbbot mrbbot added the vitest Relating to the Workers Vitest integration label Mar 26, 2024
@github-project-automation github-project-automation bot moved this to Untriaged in workers-sdk Mar 26, 2024
@mrbbot mrbbot moved this from Untriaged to Backlog in workers-sdk Mar 26, 2024
@mrbbot mrbbot self-assigned this Mar 27, 2024
@mrbbot mrbbot moved this from Backlog to In Progress in workers-sdk Mar 28, 2024
@mrbbot mrbbot moved this from In Progress to In Review in workers-sdk Mar 28, 2024
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
vitest:priority vitest Relating to the Workers Vitest integration
Projects
Status: In Review
Development

Successfully merging a pull request may close this issue.

1 participant