[Durable Objects] Add docs & changelog for eviction helpers in vitest#31686
[Durable Objects] Add docs & changelog for eviction helpers in vitest#31686apeacock1991 wants to merge 1 commit into
Conversation
|
This pull request requires reviews from CODEOWNERS as it changes files that match the following patterns:
|
9cb8ab1 to
70e3470
Compare
|
/bonk review this pr |
|
This is a well-structured PR. The documentation is clear, the examples are practical, and the fixes to existing snippets are appreciated. A few notes:
Overall this looks ready to land. Nice work on testing the examples. 👍 |
70e3470 to
5e43ed1
Compare
|
|
||
| The `@cloudflare/vitest-pool-workers` package now includes `evictDurableObject` and `evictAllDurableObjects` test helpers, exported from `cloudflare:test`. These helpers let you exercise how a Durable Object behaves across evictions in your tests. | ||
|
|
||
| Eviction is graceful: durable storage is preserved, in-memory state is reset by tearing down the instance, hibernatable WebSockets are hibernated rather than closed, and eviction waits up to 30 seconds for in-flight requests to drain. |
There was a problem hiding this comment.
As a user, I would ask "is this different than remote production behavior" because you're calling out all these things.
There was a problem hiding this comment.
Removed the references to durable storage
| date: 2026-06-25 | ||
| --- | ||
|
|
||
| The `@cloudflare/vitest-pool-workers` package now includes `evictDurableObject` and `evictAllDurableObjects` test helpers, exported from `cloudflare:test`. These helpers let you exercise how a Durable Object behaves across evictions in your tests. |
There was a problem hiding this comment.
These helpers let you exercise how a Durable Object behaves across evictions in your tests.
add something to help users why you would want to do this
There was a problem hiding this comment.
+1 and link to something that gives context on evictions maybe?
There was a problem hiding this comment.
Good shout, linked to the lifecycle doc now + gave some context on why
|
|
||
| ### Testing eviction | ||
|
|
||
| Use `evictDurableObject()` to gracefully evict a Durable Object instance during tests. Eviction tears down the instance to reset its in-memory state, while preserving durable storage. This lets you test how your Durable Object recovers state from storage after being evicted. |
There was a problem hiding this comment.
avoid graceful everywhere?
why callout saving durable storage? - if you do should be to highlight thats the product capability. otherwise I wonder "is my storage not durable"
There was a problem hiding this comment.
Fair, removed the graceful parts. They are in there because of the abort functionality, which is non-graceful but I think we can just stick with "non-graceful" or similar in the abort part.
5e43ed1 to
b9e2478
Compare
Summary
Adds docs and changelog for the new vitest helpers, which allow the testing of evictions with Durable Objects.
The implementation PR can be found here: cloudflare/workers-sdk#14398.
Note: I updated two unrelated examples because they actually failed when ran, and all the new examples have been tested and pass.
Documentation checklist