proper-lockfile

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

Library
npm
v4.1.2
285 stars
MIT License

Repository Health

Pre-computed score based on development activity, maintenance, community, maturity, and trend momentum. How we score it →
37 /100 Needs Attention
Development Activity 0
Maintenance 0
Community 68
Maturity 60
Momentum 20

Technical Analysis

AI-assessed by reading the actual repository — architecture, code quality, innovation, and documentation. How we score it →
73 /100 Good
Architecture 72
Code Quality 75
Innovation 68
Learning Curve 78

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

Architecture — index.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 10 apps in this directory

TypeScript
95%
MIT

Actual

Invoicing Finance

29,186

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
73
Dependency
Built with
TypeScript 95%
Updated 4 days ago
TypeScript
70%
Other

Budibase

Low Code Platforms · No Code Platforms

28,324

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

View details
91
Repo Health
81
Technical
63
Dependency
Built with
TypeScript 70%
Svelte 26%
Updated 1 weeks ago
TypeScript
83%
Apache 2.0

Grist

Databases · No Code Platforms

11,875

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
66
Dependency
Built with
TypeScript 83%
Python 11%
Updated 5 days ago
TypeScript
77%
Other

Joplin

Note Taking

56,513

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
60
Dependency
Built with
TypeScript 77%
JavaScript 14%
Updated 5 days ago
TypeScript
98%
MIT

Kimi Code CLI

AI Agents · AI Code Assistants · Developer Tools

7,705

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
82
Repo Health
87
Technical
67
Dependency
Built with
TypeScript 98%
Updated 4 days ago
TypeScript
39%
Apache 2.0

Label Studio

AI Development · Data Engineering

28,358

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
67
Dependency
Built with
TypeScript 39%
JavaScript 27%
Python 25%
Updated 4 days ago
TypeScript
97%
GPL 3.0

OpenKnowledge

Code Editors · Knowledge Management · Note Taking

4,337

A beautiful, local-first markdown IDE that turns any git repo into a live collaborative workspace for humans and AI coding agents like Claude, Codex, and OpenCode.

View details
79
Repo Health
89
Technical
64
Dependency
Built with
TypeScript 97%
Updated 4 days ago
TypeScript
99%
Other

openclaude

AI Agents · AI Code Assistants

33,554

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

View details
85
Repo Health
78
Technical
71
Dependency
Built with
TypeScript 99%
Updated 1 weeks ago
TypeScript
96%
MIT

Pi

AI Agents

109,828

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
74
Dependency
Built with
TypeScript 96%
Updated 5 days ago

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