npm / lockfile

A very polite lock file utility, which endeavors to not litter, and to wait patiently for others.
ISC License
260 stars 33 forks source link

Bug in project => TypeError: cb is not a function #23

Closed ORESoftware closed 7 years ago

ORESoftware commented 7 years ago

I just got this error

/home/olegzandr/Documents/WebstormProjects/poolio/node_modules/lockfile/lockfile.js:61
  fs.unlink(path, function (unlinkEr) { cb() })
                                        ^

TypeError: cb is not a function
    at /home/olegzandr/Documents/WebstormProjects/poolio/node_modules/lockfile/lockfile.js:61:41
    at FSReqWrap.oncomplete (fs.js:123:15)

Looking at the code, looks like it's a bug https://github.com/npm/lockfile/blob/master/lockfile.js

if the user doesn't pass a callback to lockFile.unlock, we will get the error

seems reasonable that the user might not want to handle any unlock errors, so the user would just call

lockFile.unlock(path);

instead of

lockFile.unlock(path, function(){});

especially since there will never be an error present in the callback given the code,

I will submit a PR

ORESoftware commented 7 years ago

https://github.com/npm/lockfile/pull/24

ORESoftware commented 7 years ago

This PR was merged, thanks! so closing