diff --git a/index.js b/index.js index 5e0ed88..2ce7ab1 100644 --- a/index.js +++ b/index.js @@ -94,8 +94,13 @@ module.exports = class RandomAccessFile extends RandomAccessStorage { // Should we aquire a read lock? const shared = self.mode === RDONLY - if (fsext.tryLock(self.fd, { shared })) onlock(null) - else onlock(createLockError(self.filename)) + try { + const didLock = fsext.tryLock(self.fd, { shared }) + if (didLock) onlock(null) + else onlock(createLockError(self.filename)) + } catch (e) { + onlock(e) + } } function onlock (err) {