moxystudio / node-proper-lockfile

An inter-process and inter-machine lockfile utility that works on a local or network file system.
MIT License
239 stars 38 forks source link

Impossible to compose a lock.. #108

Open mikegwhit opened 2 years ago

mikegwhit commented 2 years ago

when attempting to compose a release function, e.g. so that re-requesting the lock (if it exists) returns the release function, it fails stating:

TypeError: method is not a function

Example implementation:

        const release = getLock(file);
        let released = false;
        locks[file] = () => {
            if (!released) {
                released = true;
                release();
                delete locks[file];
            }
        };

Suspected cause: you're using function composition so that even with an arrow function, somehow scope is lost and method returns as undefined

mikegwhit commented 1 month ago

Still seeing this, but I may have resolved this.. it was a user error