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

fixes #29 #30

Merged
merged 4 commits into from
Feb 11, 2017
Merged

fixes #29 #30

merged 4 commits into from
Feb 11, 2017

Conversation

kp96
Copy link
Contributor

@kp96 kp96 commented Jan 31, 2017

Race condition when used with async.times

@@ -104,21 +104,22 @@ Limiter.prototype.get = function (fn) {
}

db.multi()
.set([count, n - 1, 'PX', ex * 1000 - dateNow, 'XX'])
Copy link
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I'm wondering why we didn't change it before 🤔

if (err) return fn(err);
if (isFirstReplyNull(res)) return mget();
n = n - 1;
n = Array.isArray(res[0]) ? ~~res[0][1] : ~~res[0];
Copy link
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Is it possible that the return value would not be an array?

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

If it is redis module, then res[0] is a string value. If it's ioredis then it's an array.

@noamshemesh
Copy link
Collaborator

noamshemesh commented Feb 1, 2017

In general it looks ok, thanks.
Can you please add one or two tests to simulate this problem to make sure we're fixing the race condition

@kp96
Copy link
Contributor Author

kp96 commented Feb 1, 2017

sure

@noamshemesh
Copy link
Collaborator

Hi, I'll merge it next week. I won't be near a computer till then.
Regarding Travis. I don't want to drop support for node 0.10 if it's a minor issue

@kp96
Copy link
Contributor Author

kp96 commented Feb 6, 2017

The tests are failing randomly. (off by 1 sometimes. best guess is round off errors)

@noamshemesh noamshemesh merged commit 2c4f277 into tj:master Feb 11, 2017
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

Successfully merging this pull request may close these issues.

2 participants