Skip to content

feat: add keyLocking option to disable the allow-key-locking flag - #168

Open
CahidArda wants to merge 1 commit into
mainfrom
dx-3241-ratelimit-add-flag-to-disable-key-based-locking-with-enabled
Open

CahidArda wants to merge 1 commit into
mainfrom
dx-3241-ratelimit-add-flag-to-disable-key-based-locking-with-enabled

Conversation

@CahidArda

Copy link
Copy Markdown
Contributor

Since 2.1 every Lua script starts with the Upstash-only #!lua flags=allow-key-locking shebang, which self-hosted Redis / SRH reject, so users pin back to 2.0.8.
Adds keyLocking (default true) to Ratelimit and MultiRegionRatelimit; keyLocking: false runs the scripts without the shebang, using precomputed hashes for the stripped scripts. The docstring recommends leaving it on.
Verified with new unit tests (src/key-locking-flag.test.ts: stripped hashes match SHA1, evalsha/eval get the right hash/script for single and multi region) and the existing key-locking tests; hash.test.ts also validates the stripped hashes against Redis. tsc/build errors in src/analytics.ts are pre-existing on main.
Linear: https://linear.app/upstash/issue/DX-3241/ratelimit-add-flag-to-disable-key-based-locking-with-enabled-by

Lua scripts are prefixed with `#!lua flags=allow-key-locking` since 2.1, which
self-hosted Redis and SRH reject. keyLocking: false sends the scripts without
the shebang (with their own precomputed hashes). Defaults to true.
@vercel

vercel Bot commented Nov 2, 2026 •

Copy link
Copy Markdown
Contributor

The latest updates on your projects. Learn more about Vercel for GitHub.

Project Deployment Actions Updated
ratelimit-with-vercel-kv Ready Ready Preview Nov 2, 2026 1:40pm UTC

Request Review

@linear-code

linear-code Bot commented Nov 2, 2026

Copy link
Copy Markdown

DX-3241

This branch was successfully deployed

1 active deployment
Preview — 94612f52 Deployed Nov 2, 2026 by vercel[bot]
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