Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

a few issues after trying beta 5.0.0 #297

Open
pdeveltere opened this issue Jun 4, 2024 · 0 comments
Open

a few issues after trying beta 5.0.0 #297

pdeveltere opened this issue Jun 4, 2024 · 0 comments

Comments

@pdeveltere
Copy link

pdeveltere commented Jun 4, 2024

Hi,

We are using redlock in a big project, and I started looking into upgrading since we want to upgrade ioredis to v5. A few suggestions:

  1. can we have a double signature on the acquire function so it accepts both a string and an array of strings. this will make migrating much easier for most users. And I think in general the more common usecase will be a lock on 1 resource:
public async acquire(
    resources: string | string[],
  1. why can the lock.release() still throw an error? in the examples you put lock.release() in the finally section, however this function can also throw an ExecutionError. So we would have to do something like this:
    let lock: Lock | null = null;
    try {
      lock = await redLock.acquire([`...`], 15000);
      // do some stuff
    } catch (error) {
      if (error instanceOf ResourceLockedError) {
        console.log('failed to acquire the lock on the resource');
      }
      console.log(error)
    } finally {
      await lock?.release().catch(ExecutionError, () => {
        console.log('failed to release the lock on the update. This can indicate that the lock expired prior to unlocking it');
      });
    }

this makes everything a bit convoluted. I would let the release of the lock fail silently.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

1 participant