Skip to content

Commit 4d76a85

Browse files
committed
fix: Handle synchronous exit events
1 parent c51e652 commit 4d76a85

File tree

1 file changed

+8
-1
lines changed

1 file changed

+8
-1
lines changed

lib/distributed-lock.js

+8-1
Original file line numberDiff line numberDiff line change
@@ -40,7 +40,14 @@ const onExit = callbackify(async () => {
4040
});
4141

4242
// Attempt to release any held locks if we are accidentally killed
43-
exitHook(onExit);
43+
exitHook((done) => {
44+
if (!done) {
45+
log('Skipping lock cleanup due to synchronous exit.');
46+
return;
47+
}
48+
49+
return onExit(done);
50+
});
4451

4552
class DistributedLock {
4653
constructor(lockName, params) {

0 commit comments

Comments
 (0)