feat: add key based locking to lua scripts - #20
Merged
Merged
Conversation
Contributor
|
The latest updates on your projects. Learn more about Vercel for GitHub.
|
There was a problem hiding this comment.
🟡 Changes recommended
The Lua shebang header is currently preceded by template-literal whitespace/newlines, which may prevent the allow-key-locking flag from being recognized.
Once you've addressed the issues Copilot identified, you can request another Copilot review.
Pull request overview
Adds key-based locking support for the Redis Lua scripts used by the Lock SDK, aligning behavior with Upstash’s approach in their ratelimit SDK.
Changes:
- Adds
#!lua flags=allow-key-lockingheaders to the Lua scripts used byrelease()andextend(). - Ensures unlock/extend operations can be executed with key-based locking enabled.
File summaries
| File | Description |
|---|---|
| src/lock.ts | Adds Lua script shebang flags intended to enable key-based locking for unlock/extend scripts. |
Review details
Suppressed comments (1)
src/lock.ts:163
- Same concern here: the
#!lua flags=allow-key-lockingheader is preceded by a newline/whitespace due to the way the template literal is started. If the runtime expects the shebang to be at the very beginning of the script, the flag may be ignored.
const script = `
#!lua flags=allow-key-locking
-- Check if the current UUID still holds the lock
if redis.call("get", KEYS[1]) ~= ARGV[1] then
- Files reviewed: 1/1 changed files
- Comments generated: 1
- Review effort level: Lite
💡 Add a code-review agent skill or configure MCP servers for context-aware, tailored reviews. Learn more in the docs.
Comment on lines
133
to
136
| const script = ` | ||
| #!lua flags=allow-key-locking | ||
| -- Check if the current UUID still holds the lock | ||
| if redis.call("get", KEYS[1]) == ARGV[1] then |
muhammetssen
approved these changes
Sep 9, 2026
This branch was successfully deployed
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
Adds key based locking to the lock SDK similar to the ratelimit SDK upstash/ratelimit-js#154