Durable Objects, Workers - Test Durable Object eviction with new cloudflare:test helpers
10d ago
Source
CloudflareDurable Objects, Workers - Test Durable Object eviction with new cloudflare:test helperscloudflare.comThe @cloudflare/vitest-pool-workers package now includes evictDurableObject and evictAllDurableObjects test helpers, exported from cloudflare:test . These helpers let you test how a Durable Object behaves across evictions, simulating the production lifecycle where an idle Durable Object can be evicted from memory. For more context, refer to Lifecycle of a Durable Object . import { evictDurableObject , evictAllDurableObjects } from "cloudflare:test" ; import { env } from "cloudflare:workers" ; const id = env . COUNTER . idFromName ( "my-counter" ) ; const stub = env . COUNTER . get ( id ) ; // Evict the Durable Object instance pointed to by a specific stub await evictDurableObject ( stub ) ; // Close WebSockets instead of hibernating them await evictDurableObject ( stub , { webSockets : "close" } ) ; // Evict all currently-running Durable Objects in evictable namespaces await evictAllDurableObjects () ; These helpers are available in @cloudflare/[email protected] and later. Learn more in the Test APIs reference and the Testing Durable Objects guide .
You might also wanna read
Cloudflare expands AI bot management tools with granular traffic controls for all customers
Cloudflare is celebrating the second "Content Independence Day" by expanding AI traffic management options for all website owners. Building
Workers - Simpler runtime types with @cloudflare/workers-types v5
Cloudflare·2d ago
AI Search - Manage AI Search sync jobs with Wrangler CLI
Cloudflare·3d ago
Workers - Work across multiple accounts with Wrangler auth profiles
Cloudflare·3d ago
Cache - Cache multiple versions of a URL with Vary
Cloudflare·3d ago
Cloudflare One - Hostname routing for Cloudflare Mesh
Cloudflare·3d ago

Comments
Sign in to join the conversation.
No comments yet. Be the first.