advisory-lock icon indicating copy to clipboard operation
advisory-lock copied to clipboard

When DSN is missing, lock silently fails

Open IlyaSemenov opened this issue 7 years ago • 1 comments

If DSN is not provided at all (e.g. because of the misconfigured environment), advisory-lock silently fails to lock:

> require('advisory-lock').default()('test').tryLock().then(locked => console.log('locked', locked)).catch(console.error)
> locked false

With proper DSN it works:

> require('advisory-lock').default('postgresql://localhost/test')('test').tryLock().then(locked => console.log('locked', locked)).catch(console.error)
> locked true

With wrong DSN it fails (as expected):

> require('advisory-lock').default('postgresql://localhost/no_such_db')('test').tryLock().then(locked => console.log('locked', locked)).catch(console.error)
> { error: database "no_such_db" does not exist ...

Expected behaviour

With undefined DSN, an error is thrown.

IlyaSemenov avatar Aug 01 '18 17:08 IlyaSemenov

Oops, could you send a PR?

olalonde avatar Oct 18 '18 09:10 olalonde