Skip to content

Infinite loop after new Shopify variant creation limit #81

Closed
@andyexeter

Description

@andyexeter

Shopify have introduced a limit on variant creation via API to 1000 per day for stores with over 50,000 variants: https://developers.shopify.com/changelog/api-call-limits-will-be-applied-to-variant-creation.

When this limit is reached the response code is 429 Too Many Requests. This means the following code gets caught in an infinite loop:

protected static function processRequest($ch)
{
# Check for 429 leaky bucket error
while(1) {
$output = curl_exec($ch);
self::$lastHttpCode = curl_getinfo($ch, CURLINFO_HTTP_CODE);
if(self::$lastHttpCode != 429) {
break;
}
usleep(500000);
}

I'm not sure of the best way around this, but I'm happy to submit a PR after some feedback. We could check the response body and throw an exception to break out of the loop? The response body when this limit is hit is:

{
  "errors": {
    "product": [
      "Daily variant creation limit reached. Please try again later. See https://help.shopify.com/en/api/getting-started/api-call-limit for more information about rate limits and how to avoid them."
    ]
  }
}

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions