{"action":"opened","issue":{"url":"https://api.github.com/repos/dudleycarr/ratelimit.js/issues/40","repository_url":"https://api.github.com/repos/dudleycarr/ratelimit.js","labels_url":"https://api.github.com/repos/dudleycarr/ratelimit.js/issues/40/labels{/name}","comments_url":"https://api.github.com/repos/dudleycarr/ratelimit.js/issues/40/comments","events_url":"https://api.github.com/repos/dudleycarr/ratelimit.js/issues/40/events","html_url":"https://github.com/dudleycarr/ratelimit.js/issues/40","id":330582032,"node_id":"MDU6SXNzdWUzMzA1ODIwMzI=","number":40,"title":"Should this work across multiple instantiations of RateLimit?","user":{"login":"mhelvens","id":4012816,"node_id":"MDQ6VXNlcjQwMTI4MTY=","avatar_url":"https://avatars1.githubusercontent.com/u/4012816?v=4","gravatar_id":"","url":"https://api.github.com/users/mhelvens","html_url":"https://github.com/mhelvens","followers_url":"https://api.github.com/users/mhelvens/followers","following_url":"https://api.github.com/users/mhelvens/following{/other_user}","gists_url":"https://api.github.com/users/mhelvens/gists{/gist_id}","starred_url":"https://api.github.com/users/mhelvens/starred{/owner}{/repo}","subscriptions_url":"https://api.github.com/users/mhelvens/subscriptions","organizations_url":"https://api.github.com/users/mhelvens/orgs","repos_url":"https://api.github.com/users/mhelvens/repos","events_url":"https://api.github.com/users/mhelvens/events{/privacy}","received_events_url":"https://api.github.com/users/mhelvens/received_events","type":"User","site_admin":false},"labels":[],"state":"open","locked":false,"assignee":null,"assignees":[],"milestone":null,"comments":0,"created_at":"2018-06-08T09:18:31Z","updated_at":"2018-06-08T09:18:31Z","closed_at":null,"author_association":"NONE","body":"Start with this scenario:\r\n\r\n```js\r\nconst limiter = new RateLimit(\r\n  redis,\r\n  [{ interval: 100, limit: 3 }],\r\n  { prefix: redis.keyPrefix, clientPrefix: true }\r\n)\r\nconst key = 'single-key'\r\nexpect(await promisify(limiter, 'incr')(key)).toBe(false)\r\nexpect(await promisify(limiter, 'incr')(key)).toBe(false)\r\nexpect(await promisify(limiter, 'incr')(key)).toBe(false)\r\nexpect(await promisify(limiter, 'incr')(key)).toBe(true)\r\nawait promisify(setTimeout)(200)\r\nexpect(await promisify(limiter, 'incr')(key)).toBe(false)\r\n```\r\n\r\nThat works as expected, the test passes. However:\r\n\r\n```js\r\nconst createLimiter = () => new RateLimit(\r\n  redis,\r\n  [{ interval: 100, limit: 3 }],\r\n  { prefix: redis.keyPrefix, clientPrefix: true }\r\n)\r\nconst key = 'single-key'\r\nexpect(await promisify(createLimiter(), 'incr')(key)).toBe(false)\r\nexpect(await promisify(createLimiter(), 'incr')(key)).toBe(false)\r\nexpect(await promisify(createLimiter(), 'incr')(key)).toBe(false)\r\nexpect(await promisify(createLimiter(), 'incr')(key)).toBe(true)\r\nawait promisify(setTimeout)(200)\r\nexpect(await promisify(createLimiter(), 'incr')(key)).toBe(false)\r\n```\r\n\r\nThis does not pass. The very last assertion fails, no matter how long I set that timeout. Is this expected?"}}
{"actor":{"display_login":"mhelvens"}}