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
mutex.waitForUnlock() bug? #52
Comments
Sorry for the late reply. Indeed, you're right, I checked the code, if there are more tasks blocked in the queue, then the semaphore will have decremented again before the waiter is resolved. This will still happen at the correct time (after the previous task has released the mutex and before the next task has acquired it, but this is not reflected by I'll add a fix in the next release. |
i am facing the same issue |
Fixed in 0.4.0 |
Not sure if this is a bug or if I'm using it incorrectly.
version: 0.3.2
node: v16.6.1
typescript: Version 4.5.5
const myMutex = new Mutex();
await myMutex.runExclusive( async () => {
await myAsyncFunc();
});
// now wait until unlocked ...
await myMutex.waitForUnlock();
if(myMutex.isLocked()) throw new Error('myMutex is locked'); // <== this throws the error all the time
// instead, this works fine
const releaser = await myMutex.acquire();
releaser();
if(myMutex.isLocked()) throw new Error('myMutex is locked); // <== never throws, it works
BTW, awesome library!
The text was updated successfully, but these errors were encountered: