proper-lockfile

An inter-process and inter-machine lockfile utility for local and network file systems

Library
npm
v4.1.2
284stars
MIT License

Repository Health

Pre-computed score based on development activity, maintenance, community, maturity, and trend momentum.How we score it →
37/100Needs Attention
Development Activity0
Maintenance0
Community68
Maturity60
Momentum20

Technical Analysis

AI-assessed by reading the actual repository — architecture, code quality, innovation, and documentation.How we score it →
73/100Good
Architecture72
Code Quality75
Innovation68
Learning Curve78

proper-lockfile provides cooperative file locking across processes and even across machines sharing a network file system. Rather than relying on open() with O_EXCL (which is broken on NFS), it uses the mkdir strategy, which is atomic on essentially every filesystem, and creates a .lock suffixed directory next to the file being locked.

To guard against stale locks from crashed processes, it periodically refreshes the lockfile’s mtime while held and lets callers configure a staleness threshold; if the update fails or the lock is found compromised, an onCompromised callback fires. Both promise-based (.lock/.unlock/.check) and synchronous (.lockSync/.unlockSync/.checkSync) APIs are provided, and locks are automatically released on graceful process exit.

What You Get

  • Promise-based .lock()/.unlock()/.check() API plus synchronous .lockSync()/.unlockSync()/.checkSync() equivalents
  • Atomic mkdir-based locking that works correctly on local and network file systems, unlike O_EXCL-based alternatives
  • Configurable staleness detection via periodic mtime updates, with a stale threshold and update interval
  • An onCompromised hook fired if a held lock’s mtime updates start failing or a lock is found tampered with
  • Automatic lock release on graceful process exit (not guaranteed on SIGKILL or VM fatal errors)

Common Use Cases

  • Preventing concurrent writes to a shared cache, config, or database file from multiple Node.js processes
  • Coordinating access to a resource shared across machines on a network file system
  • Guarding CLI tools that must not run two instances against the same working directory simultaneously
  • Implementing safe, crash-tolerant single-writer semantics for build or deployment scripts

Under The Hood

Architectureindex.js is a thin public-facing wrapper exposing the six lock/unlock/check (sync and async) functions, delegating the actual locking mechanics to lib/lockfile.js, which implements the mkdir-based acquire/release/check logic, staleness detection, and the periodic mtime-refresh timer. lib/adapter.js abstracts the filesystem calls (supporting a pluggable fs, defaulting to graceful-fs), and lib/mtime-precision.js detects the filesystem’s mtime precision to avoid false-positive staleness on filesystems with coarse timestamp resolution.

Tech Stack — Plain Node.js (CommonJS), with graceful-fs as the default filesystem backend and the retry package available for configurable lock-acquisition retry policies. No build step; the library ships as-is from lib/ and index.js.

Code Quality — Tests run via Jest with coverage (jest --env node --coverage --runInBand), and the README explicitly notes ‘the test suite is very extensive’ including a stress test for lock exclusivity guarantees. The library is feature-frozen and has seen no commits since 2023, per the health-score data, but its narrow, well-defined scope means the risk from staleness is low for a locking primitive with this test depth.

API Design — Six clearly-named functions (lock/unlock/check × sync/async) cover the entire public surface, and the async .lock() returns a release function directly rather than requiring a separate unlock call with the original path — reducing the chance of releasing the wrong resource. Sensible option defaults (stale: 10000, update: stale/2) mean most callers need zero configuration to get safe behavior out of the box.

Used by 8 apps in this directory

TypeScript
94%
MIT

Actual

Invoicing Finance

28,224

Local-first personal finance with envelope budgeting, end-to-end encryption, and multi-device sync — no subscription required.

View details
93
Repo Health
85
Technical
77
Dependency
Built with
TypeScript94%
Updated yesterday
TypeScript
69%
Other

Budibase

Low Code Platforms · No Code Platforms

28,220

Build AI agents, automations, and internal apps on a single open-source platform with full self-hosting control.

View details
92
Repo Health
81
Technical
63
Dependency
Built with
TypeScript69%
Svelte26%
Updated today
TypeScript
83%
Apache 2.0

Grist

Databases · No Code Platforms

11,469

A modern relational spreadsheet that combines Python-powered formulas, drag-and-drop dashboards, and granular access controls in a self-hostable, SQLite-backed data platform.

View details
91
Repo Health
93
Technical
68
Dependency
Built with
TypeScript83%
Python11%
Updated yesterday
TypeScript
76%
Other

Joplin

Note Taking

56,003

The privacy-first, open-source note-taking app with end-to-end encrypted sync, AI assistance, and a powerful plugin ecosystem across every platform.

View details
93
Repo Health
87
Technical
62
Dependency
Built with
TypeScript76%
JavaScript15%
Updated yesterday
TypeScript
98%
MIT

Kimi Code CLI

AI Code Assistants · AI Agents · Developer Tools

6,908

A single-binary, terminal-native coding agent that reads, edits, and runs code end to end, built by Moonshot AI for Kimi models but pluggable with Anthropic, OpenAI, and Google providers too.

View details
81
Repo Health
87
Technical
66
Dependency
Built with
TypeScript98%
Updated today
TypeScript
38%
Apache 2.0

Label Studio

AI Development · Data Engineering

28,083

Label Studio is an open-source, multi-type data labeling platform that lets teams annotate images, text, audio, video, and time series data with a configurable XML-based UI and export annotations in formats ready for any ML framework.

View details
93
Repo Health
87
Technical
68
Dependency
Built with
TypeScript38%
JavaScript27%
Python25%
Updated today
TypeScript
99%
Other

openclaude

AI Agents · AI Code Assistants

30,767

Run Claude Code workflows against any LLM — OpenAI, Gemini, Ollama, and 200+ backends — from a single terminal-first CLI.

View details
86
Repo Health
78
Technical
84
Dependency
Built with
TypeScript99%
Updated today
TypeScript
94%
MIT

Pi

AI Agents

93,473

An open-source, self-extensible agent harness and coding agent CLI — a modular runtime (agent core, unified multi-provider LLM API, TUI) with no built-in permission system by default, documented containerization patterns for sandboxing instead.

View details
88
Repo Health
73
Technical
76
Dependency
Built with
TypeScript94%
Updated today

Join founders buildingwith open source

Opinionated takes, migration guides, cost-saving tips, and insights from the open source ecosystem.

Subscribe on Substack
Join 750+ subscribers

Search