@@ -154,6 +154,36 @@ For multi-worker deployments, use a `KvStore` implementation that supports
154154Fedify still works without CAS, but it logs a warning because concurrent
155155workers can race when opening or closing the same host's circuit.
156156
157+ Fedify expires stored circuit state after it is no longer useful. With the
158+ default numeric failure policy, the default ` stateTtl ` is derived from
159+ ` failureWindow ` , ` recoveryDelay ` , and ` heldActivityTtl ` so failure history,
160+ recovery probes, and held activities all have enough time to complete. If you
161+ provide a custom ` failure ` callback, Fedify cannot infer how long your policy
162+ needs its timestamp history, so stored state does not expire by default. Set
163+ ` stateTtl ` explicitly when using a custom policy and you want circuit state to
164+ be cleaned up automatically:
165+
166+ ~~~~ typescript
167+ const federation = createFederation <void >({
168+ kv ,
169+ queue ,
170+ circuitBreaker: {
171+ failure(timestamps ) {
172+ return timestamps .length >= 10 ;
173+ },
174+ stateTtl: { days: 14 },
175+ },
176+ });
177+ ~~~~
178+
179+ When upgrading from Fedify 2.3.0 or 2.3.1, Fedify automatically rewrites
180+ legacy circuit state with a TTL only on ` KvStore ` implementations that support
181+ ` cas() ` . Stores without CAS, including ` @fedify/postgres ` and
182+ ` @fedify/redis ` , apply TTLs to new circuit state but cannot automatically
183+ clean up circuit state that was already written without a TTL. If that old
184+ state matters for your deployment, remove it with a one-off cleanup script or
185+ add a TTL directly in your storage backend.
186+
157187
158188Observability
159189-------------
0 commit comments