Skip to content

STOR-5343: Add unsafe Durable Object eviction for tests#6841

Closed
apeacock1991 wants to merge 1 commit into
mainfrom
apeacock/testing-evictions
Closed

STOR-5343: Add unsafe Durable Object eviction for tests#6841
apeacock1991 wants to merge 1 commit into
mainfrom
apeacock/testing-evictions

Conversation

@apeacock1991

Copy link
Copy Markdown
Contributor

Add test-only unsafe Durable Object eviction support for workerd. This introduces server-side eviction plumbing that reuses the existing idle eviction path, then exposes it through unsafe.evict(stub) and unsafe.evictAllDurableObjects().

The eviction path waits for live requests to drain, preserves durable storage, and hibernates hibernatable WebSockets instead of aborting actors. It also respects preventEviction and keeps actor broken-monitoring intact when eviction is skipped because the actor still has active references.

The bulk path walks actor facets recursively so evictAllDurableObjects() covers the currently-running actor tree. Targeted eviction rejects non-Durable Object stubs and rejects objects that have not been instantiated yet, while bulk eviction skips idle/non-running actors.

Tests cover storage preservation, in-memory state reset, in-flight requests, concurrent evictions, preventEviction, non-DO inputs, bulk eviction, and WebSocket hibernation.

Workers SDK PR: cloudflare/workers-sdk#14398

@apeacock1991 apeacock1991 requested review from a team as code owners June 23, 2026 16:19
@github-actions

github-actions Bot commented Jun 23, 2026

Copy link
Copy Markdown

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

@apeacock1991

Copy link
Copy Markdown
Contributor Author

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

github-actions Bot added a commit that referenced this pull request Jun 23, 2026
@ask-bonk

ask-bonk Bot commented Jun 23, 2026

Copy link
Copy Markdown
Contributor

LGTM

github run

Add test-only unsafe Durable Object eviction support for workerd. This introduces server-side eviction plumbing that reuses the existing idle eviction path, then exposes it through unsafe.evict(stub, options) and unsafe.evictAllDurableObjects(options).

The eviction path waits for live requests to drain, preserves durable storage, and hibernates hibernatable WebSockets by default. Callers can pass options.webSockets = "close" to close hibernatable WebSockets instead while still preserving storage and allowing the actor to be rebuilt on the next request.

The implementation respects preventEviction and keeps actor broken-monitoring intact when eviction is skipped because the actor still has active references. The bulk path walks actor facets recursively so evictAllDurableObjects() covers the currently-running actor tree, waits for all sibling evictions before reporting errors, and keeps each eviction coroutine pinned while it can be suspended.

Targeted eviction rejects non-Durable Object stubs and rejects objects that have not been instantiated yet, while bulk eviction skips idle/non-running actors. Tests cover storage preservation, in-memory state reset, in-flight requests, concurrent evictions, preventEviction, non-DO inputs, invalid options, bulk eviction, facet recursion, WebSocket hibernation, and WebSocket close mode.
@apeacock1991 apeacock1991 force-pushed the apeacock/testing-evictions branch from 106889c to 9dc0a02 Compare June 23, 2026 16:31
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