Random 500 Internal Server Error on updating Product via API

New Member
3 0 0

Hi~

 

We've been getting small amount of 500 internal server errors when calling PUT /admin/products/#{product_id}.json starting end of last year. The number of errors suddenly shot up about ten-fold (to ~40 errors a day) starting around 1/16 of this year.

 

Problem does not seem to be product specific. We tested by generating ~290 products in JSON onto a file. Then process the file twice, updating 1 product at a time (with sleep time in between to prevent hitting threshold). First run we got 2 "500 internal server error"; second run we got 4, on different products each time.

 

Any help / advice is greatly appreciated, or if there's some data that I can post that would help better diagnose this issue. Thank you!

0 Likes
Excursionist
26 1 5

Is the 500 returned by Shopify or by your own service that calls Shopify? When you're making those calls, do you monitor the value returned in the X-Shopify-Shop-Api-Call-Limit header? You should, and then do the sleeps based on that. https://help.shopify.com/en/api/getting-started/api-call-limit

0 Likes
Highlighted
Shopify Expert
9420 11 1262

Adding a sleep isn't a reliable way handle call rates. You should be looking at the actual queue, or making your sleep so large that it doesn't matter about the queue. What actions do you take when the call limit is hit?

★ Winning Partner of the Build a Business competition. ★ http://freakdesign.com.au
0 Likes
New Member
3 0 0

Thank you so much for the response!

  • 500 appears to be returned by Shopify, because our code deals with 429 Too Many Requests exception separately~
  • Thanks for the tip! We'll update our code to utilize that header. I'll re-test the file tomorrow to see what that value is before the 500 server error occurs.

Instinctively this doesn't feel like threshold issue though, we've seemed separate error email for 429 before (hence the additional code to deal with it to prevent excessive error emails from our code). Plus we've processed the same number of products in the same order twice, so it should fail more or less close to the same spot, or at least have same number of failures. But new ideas are really helpful, we'll update our code accordingly and test again, thank you!

0 Likes
New Member
3 0 0

Thanks for your response!

  • We currently sleep 500ms per request, and when we hit 429 Too Many Requests exception, we sleep in increment of 500ms (500 x 1, 500 x 2, 500 x 4, and so on...) per request until the request is processed.
  • We'll modify our code to utilize the X-Shopify-Shop-Api-Call-Limit header in the future, but not 100% sure if the current error is caused by threshold limit.

Thank you!

0 Likes