Skip to content

Implement a state adapter based on KV2#82

Draft
cramforce wants to merge 1 commit intomainfrom
kv2
Draft

Implement a state adapter based on KV2#82
cramforce wants to merge 1 commit intomainfrom
kv2

Conversation

@cramforce
Copy link
Contributor

Summary

Test plan

@vercel
Copy link
Contributor

vercel bot commented Feb 21, 2026

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

Project Deployment Actions Updated (UTC)
chat Ready Ready Preview, Comment, Open in v0 Feb 21, 2026 10:21pm

@github-actions
Copy link
Contributor

Preview Branch Testing

To test this PR with real webhook traffic:

  1. Go to /settings on the production deployment
  2. Enter this PR's Vercel preview URL
  3. Save — all webhook requests will now be proxied to this preview

To disable: Clear the URL on the settings page.

@socket-security
Copy link

Review the following changes in direct dependencies. Learn more about Socket for GitHub.

Diff Package Supply Chain
Security
Vulnerability Quality Maintenance License
Added@​vercel/​kv2@​0.0.11771009798100

View full report

Comment on lines +201 to +202
await this.locks.delete(lock.threadId);
} catch (error) {
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Suggested change
await this.locks.delete(lock.threadId);
} catch (error) {
// Use version-checked update instead of unversioned delete to avoid
// racing with another process that acquired the lock between our read
// and this write. Setting expiresAt to 0 marks it as expired so
// acquireLock will treat it as available.
await existing.update({
token: value.token,
expiresAt: 0,
});
} catch (error) {
if (error instanceof KVVersionConflictError) {
// Another process already took over the lock — safe to ignore
return;
}

Race condition in releaseLock: unversioned this.locks.delete() can delete another process's lock that was acquired between the token check and the delete.

Fix on Vercel

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