You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
{{ message }}
Repository navigation
Constructor renews the sleepAfter timer: any call into an evicted Container object extends the container's life #264
sleepAfterMs lives only in memory, and the Container constructor calls renewActivityTimeout(). When the Durable Object has been evicted while its container is still running, any call that re-creates it, such as a custom RPC method that never touches the container, resets the sleep deadline to now + sleepAfter. Activity that never reached the container keeps it running, and billing, for another full sleepAfter.
renewActivityTimeout() sets this.sleepAfterMs = Date.now() + sleepAfter (L770–773). The field is an in-memory instance field (sleepAfterMs = 0, L1024). The time of the container's last real activity is not persisted, so a new instance cannot tell how long the container has been idle.
Requests to the container at 00:15:20–00:15:52 UTC. The object's state, read by a read-only RPC method (state(), which only reads fields), showed bornAt 00:15:20, sleepAt 00:30:36.
No traffic for 5 minutes.
The same RPC at 00:20:53 showed bornAt 00:20:53 (the object had been re-created by that call) and sleepAt 00:35:53. The deadline had moved 5 minutes later, with no request to the container in between.
A deploy-time health check that calls into each object, or any periodic read-only RPC, can therefore keep containers awake indefinitely.
Expected
The time of the container's last activity survives re-creation of the object, for example in storage, alongside the alarm. A non-containerFetch call into the object should not count as container activity.
The same effect in production, with no calls from us. Container application with sleepAfter = '15m', @cloudflare/containers 0.3.7. Times are UTC, 2026-10-19, taken from Workers Logs.
05:55:50 is the last request to the container. It was a GET /api/health; the event is logged at its end, 05:58:49, with wallTimeMs 178713.
The deadline is therefore 06:10:50.
The Durable Object then reset itself:
06:01:05 alarm canceled
06:01:31 alarm exception
06:01:31 Connection closed: this Durable Object instance is no longer active. Reconnect or retry the request.
The next alarms run on a new instance, and the stop comes at 06:01:05 + 15:00:
The container ran 5 minutes 14 seconds past sleepAfter because the re-created instance's constructor called renewActivityTimeout(). Nothing reached the container after 05:55:50.
For comparison, three later cycles on the same application, where the object was not re-created, stopped 15:00–15:01 after the last request: 06:17:27 → 06:32:27, 06:34:16 → 06:49:17, 07:05:39 → 07:20:40.
Activity
Berik2001 commentedon Oct 19, 2026
The same effect in production, with no calls from us. Container application with
sleepAfter = '15m',@cloudflare/containers0.3.7. Times are UTC, 2026-10-19, taken from Workers Logs.05:55:50is the last request to the container. It was aGET /api/health; the event is logged at its end,05:58:49, withwallTimeMs 178713.06:10:50.06:01:05 + 15:00:The container ran 5 minutes 14 seconds past
sleepAfterbecause the re-created instance's constructor calledrenewActivityTimeout(). Nothing reached the container after 05:55:50.For comparison, three later cycles on the same application, where the object was not re-created, stopped 15:00–15:01 after the last request: 06:17:27 → 06:32:27, 06:34:16 → 06:49:17, 07:05:39 → 07:20:40.