Skip to content

Correct two Deno KV limits: total key size and default list batch size - #3558

Open
basartuncay wants to merge 1 commit into
denoland:mainfrom
basartuncay:fix-kv-limits
Open

basartuncay wants to merge 1 commit into
denoland:mainfrom
basartuncay:fix-kv-limits

Conversation

@basartuncay

Copy link
Copy Markdown

Two numbers on the Deno KV pages do not match what Deno does. I ran into them while writing a compatibility layer that mirrors Deno KV's limits.

1. Max total size of keys in an atomic operation (deploy/kv/transactions.md)

The page says 90 KiB and that it includes keys in checks. Deno enforces 80 KiB (81,920 bytes), and only for mutations that write a value:

  • MAX_TOTAL_KEY_SIZE_BYTES = 80 * 1024 in ext/kv/config.rs
  • in ext/kv/lib.rs, total_key_size is only increased in the loop over mutations that have a value; keys of checks and deletes are added to total_payload_size only
  • tests/unit/kv_test.ts expects Total key size too large (max 81920 bytes)

2. Default batch size of kv.list() (deploy/kv/operations.md)

The page says 500. In ext/kv/01_db.ts it is options.batchSize ?? (options.limit ?? 100), capped at 500 only when batchSize was not passed. So the default is 100, or the limit when one is set, up to 500.

Checked on Deno 2.9.8 (deno run --unstable-kv, Deno.openKv(":memory:"), keys of about 2,000 bytes):

Atomic operation Result
40 set (about 80,000 bytes of keys) commits
41 set Total key size too large (max 81920 bytes)
45 sum Total key size too large (max 81920 bytes)
45 delete commits
100 check plus one small set commits

Not checked: the hosted Deno Deploy KV backend. If its key limit really is 90 KiB, I am happy to change the sentence so it names both values.

Both pages get a new last_modified, and deno fmt was run on them.

A note on a related spot, not changed here: the batchSize JSDoc in lib.deno.unstable.d.ts says larger values are clamped to 500, while an explicit batchSize: 1000 works and 1001 throws Too many entries (max 1000). I can send that to denoland/deno separately if it is wanted.

Disclosure: this change was prepared with AI assistance (Claude Code); the behaviour above was run and read before opening the pull request.

🤖 Generated with Claude Code

Co-Authored-By: Claude Fable 5.2 <noreply@anthropic.com>

This branch has not been deployed

No deployments
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