Closed roberttolton closed 3 years ago
I believe it is a bug. I believe it needs to be a less than.
@osiset Wouldn't less-than-or-equal be fine? Because having 2 requests per second is fine, just not more than that. Right?
Yes it should be fine that way. You're welcome to try it out and see if it fixes your issue. If so you can submit a PR. I'm unfortunately tied up this week :(
@osiset No worries - I'll work on this tomorrow and send up a PR.
Hi,
Thanks for your work on the package by the way.
I've trying to use it in a serverless environment - AWS Lambda with Laravel Vapor.
I have created a class that implements
StateStorage
in order to put the rate limits, timings etc into a shared cache instance:I can see the cache data getting set correctly, as such:
However, when I'm running this, it constantly hits Shopify API Limits, and it seems like it doesn't even try to slow down.
Looking at the source files, I see the
handleRest()
function counts the number of elements in the above array, indexed by session / shop name. But why the!==
check and not less-than-or-equal<=
?Considering that the elements in the cached array fill-up rapidly from multiple Lambda functions, I quickly get more elements than the
getRestLimit()
, which is2
, so the function exits on thereturn false
because10 !== 2
and never triggers the sleep.@osiset Am I missing something here? Apologies if so.