Never worry about race conditions again!

LockDB is a cross-platform tool you can use to handle process/event locking and avoid race conditions. It is sometimes also known as a semaphore.

There are packages for Node.js / Browser / Bun / NPM, Deno, and you can also use it as a CLI.

If you need to handle locking, you've come to the right place.

Start a 30-day free trial!

No credit card required.
$15 / month or $150 / year after.

import LockDB from 'lockdb';

const locker = new LockDB('reports', { apiKey: 'api-key' });

// Obtain a lock, waiting up to 30 seconds
const lockName = 'sales';
try {
  await locker.lock(lockName);

  // Generate important/intensive report here

  // Unlock after the work is done
  await locker.unlock(lockName);
} catch (error) {
  console.error('Failed to obtain lock');

Frequently asked questions

How much does it cost?

$15 / month or $150 / year, after a 30-day free trial (no credit card required). It's unmetered usage.

Can I use this with my own locking server?

Yes, and for free! You just need to implement your own server, and then pass around the serverUrl parameter to the commands. You can see the mock test server for a very basic implementation starting point.

Can I use this with Node.js/Bun or in the browser?

Yes, there is an NPM package available.

Can I use this with Deno?

Yes, there is a Deno package available.

Can I use this with another language like Python, Rust, or Go?

Yes, there is a CLI available to install in macOS, Linux, or Windows.