deno
f4d7aef3 - chore: require a distributed KV database via env var (#35671)

Commit
26 days ago
chore: require a distributed KV database via env var (#35671) A platform that attaches Deno KV databases out-of-band (for example Deno Deploy) has no way today to make a missing database obvious. When no database is attached, `Deno.openKv()` either is not exposed at all, so calling it reports the confusing "Deno.openKv is not a function", or it silently falls back to a per-isolate in-memory store whose data never persists and is not shared between instances. This adds a `DENO_KV_REQUIRES_DISTRIBUTED_DATABASE` env var that controls what happens when `Deno.openKv()` would resolve to a local or in-memory store rather than a distributed (remote) database. Set to `error`, the KV API is force-exposed even without `--unstable-kv` and the open rejects with a clear "no KV database is attached" message. Set to `warn`, the local fallback is still allowed but a warning is logged once. When the var is unset, behavior is unchanged. A distributed database is one served over http(s), matching the remote KV backend. Co-authored-by: Bert Belder <bertbelder@gmail.com>
Author
Parents
Loading