Locks
Locks
Distributed mutexes backed by Durable Objects. Use locks to guarantee mutually exclusive access to a critical section for a given key across stateless workers.
Lease-based locking: Every acquisition includes a TTL. Renew the lease while work is in progress, and rely on expiration to recover automatically if a worker crashes mid-flight.
Acquire Lock
GET
typescript
const lock = await ss.infra.locks.acquire('invoice:ord_123', {
ttl_ms: 15000,
holder_id: 'worker-1',
})
// lock.token, lock.expires_at
- Open Dashboard → Locks and select your project
- Enter the lock key, optional holder ID, and TTL
- Click Acquire to lease the key and capture the token in the dashboard
Locks are key-driven leases, so the dashboard works from a known key instead of a global list.
Release Lock
GET
typescript
await ss.infra.locks.release('invoice:ord_123', {
token: lock.token,
})
- Open Dashboard → Locks and select your project
- Enter the same lock key and paste the token from acquisition
- Click Release to free the lease
The dashboard gives you direct control over a known lock key, even though the runtime does not expose a browsable lock index.
Renew Lock
GET
typescript
await ss.infra.locks.renew('invoice:ord_123', {
token: lock.token,
ttl_ms: 15000,
})
- Open Dashboard → Locks and select your project
- Enter the lock key, current token, and the new TTL
- Click Renew before the current lease expires
Renew is still designed for long-running workers, but the dashboard is useful for manual recovery and debugging.
Get Lock Status
GET
typescript
const status = await ss.infra.locks.status('invoice:ord_123')
// status.locked, status.expires_at, status.holder_id
- Open Dashboard → Locks and select your project
- Enter the exact lock key you want to inspect
- Click Status or Inspect key to view the lease state
There is still no global lock listing, so inspection is intentionally key-by-key.