diff --git a/lib/lockfile.js b/lib/lockfile.js index 97b6637..ba931c4 100644 --- a/lib/lockfile.js +++ b/lib/lockfile.js @@ -75,7 +75,13 @@ function acquireLock(file, options, callback) { return callback(err); } - acquireLock(file, { ...options, stale: 0 }, callback); + acquireLock(file, { ...options, stale: 0 }, (err) => { + if (!err) { + // Only notify when the lock was actually acquired to make sure only one process can reclaim + options.onReclaimedStale && options.onReclaimedStale(); + } + callback(err); + }); }); }); });