question-mark
Stuck on an issue?

Lightrun Answers was designed to reduce the constant googling that comes with debugging 3rd party libraries. It collects links to all the places you might be looking at while hunting down a tough bug.

And, if you’re still stuck at the end, we’re happy to hop on a call to see how we can help out.

autoLimit should actually check Shopify response and wait to retry

See original GitHub issue

Hi,

We’re looking at switching to this library instead of https://github.com/christophergregory/shopify-node-api

There’s an issue with autoLimit. The other library accepted a limit and it automatically checks Shopify’s response with the remaining limit, and waits until it retries again. Simply said, it just works, we never had to worry about limits. Some calls will take longer to return.

Here we tried

autoLimit: { calls: 1, interval: 1000, bucketSize: 16 }, 

according to https://github.com/MONEI/Shopify-api-node/issues/135

and it still gives error

"statusCode": 429,
	"statusMessage": "Too Many Requests",

after ~10 seconds.

We can see the Shopify limit decreasing with .on('callLimits'), but the library seems to ignore it. Could it check that and wait automatically?

Checking it would also help if having multiple instances making simultaneous calls. Since the current limit is always returned by Shopify, no need to worry what limits to set in each case.

Thanks

Issue Analytics

  • State:closed
  • Created 4 years ago
  • Comments:5

github_iconTop GitHub Comments

4reactions
joantunecommented, Jan 14, 2020

Also - the Retry-after header exists for the same purpose - from Shopify’s docs: https://help.shopify.com/en/api/reference/rest-admin-api-rate-limits

    Use the rate limits header to balance your request volume.

Handling exceeded rate limits

If your app is throttled, then it won't be able to make any more requests until enough time has passed and your bucket has capacity again. You can calculate this wait time manually using the bucket size and leak rate properties, or by using the Retry-After response header. Your app can also use a more general exponential backoff algorithm to complete the call at a later time.
2reactions
joantunecommented, Jan 14, 2020

@lpinca - ‘just use a queue’ - erm we have a hint from the server on both the response code and the headers. Why is it wrong? it’s definitely something I’m willing to implement - as it’s much easier than the answer of: change your whole architecture Serverless? tough luck - make it a queue somehow… that somehow takes into account the time…

Read more comments on GitHub >

github_iconTop Results From Across the Web

An Introduction to Rate Limits - Shopify
Learn how API rate limits work at Shopify, including the different types of requests through GraphQL and REST, and Shopify's leaky bucket ...
Read more >
Response code 429 (Too Many Requests) After making 20k ...
My question is regarding Retry-After Header. As per standards Retry-After can give the waiting timing in seconds or in hours and may be...
Read more >
How to Optimize API Rate Limits - Shopify
Given that the amount of time we're waiting for requests is roughly about a second, this math should check out. Now I expect...
Read more >
Solved: Billing Attempt with no completion, error or next action
I would suggest to retry billing the subscription contract with a different ... that checks if the BA id from the response that...
Read more >
Hitting REST API Limits (429) when doing very few "orders ...
The response message is confusing too, I'll raise this internally. ... When I do hit the issue, and wait 10 seconds and try...
Read more >

github_iconTop Related Medium Post

No results found

github_iconTop Related StackOverflow Question

No results found

github_iconTroubleshoot Live Code

Lightrun enables developers to add logs, metrics and snapshots to live code - no restarts or redeploys required.
Start Free

github_iconTop Related Reddit Thread

No results found

github_iconTop Related Hackernoon Post

No results found

github_iconTop Related Tweet

No results found

github_iconTop Related Dev.to Post

No results found

github_iconTop Related Hashnode Post

No results found