Overview
ShopifyAPI::Clients::HttpClient#request calls HTTParty without a timeout, so every Admin API request uses Net::HTTP's default 60-second read timeout. When Shopify is slow to send the first byte, the calling thread waits for as long as that takes. On a web server, that thread is a request worker.
In production we saw a stalled Admin GraphQL read hold a Puma thread for 27.5s, while our p99.9 for the same calls is about 2s. The client has no supported way to set a shorter limit. The only workaround is to monkey-patch HTTParty.
Proposal
Add optional open_timeout and read_timeout (seconds) to ShopifyAPI::Context.setup, and pass them to HTTParty on every request:
ShopifyAPI::Context.setup(
# other params...
open_timeout: 5,
read_timeout: 10,
)
When they aren't set, behaviour stays exactly as it is today. A timeout raises Net::OpenTimeout or Net::ReadTimeout out of the client; the existing retry loop only retries 429/500 responses, so a timeout isn't retried.
Related
This proposal is deliberately narrower: just the two timeouts, as typed Context settings. That keeps the change small and easy to review, and doesn't commit the gem to exposing all of HTTParty's options. If maintainers prefer the general approach in #1376, that covers this too.
Overview
ShopifyAPI::Clients::HttpClient#requestcalls HTTParty without a timeout, so every Admin API request uses Net::HTTP's default 60-second read timeout. When Shopify is slow to send the first byte, the calling thread waits for as long as that takes. On a web server, that thread is a request worker.In production we saw a stalled Admin GraphQL read hold a Puma thread for 27.5s, while our p99.9 for the same calls is about 2s. The client has no supported way to set a shorter limit. The only workaround is to monkey-patch HTTParty.
Proposal
Add optional
open_timeoutandread_timeout(seconds) toShopifyAPI::Context.setup, and pass them to HTTParty on every request:When they aren't set, behaviour stays exactly as it is today. A timeout raises
Net::OpenTimeoutorNet::ReadTimeoutout of the client; the existing retry loop only retries 429/500 responses, so a timeout isn't retried.Related
HTTPartyoptions inShopifyAPI::Clients::HttpClient#1456 asks for arbitrary HTTParty options to be passed through.httparty_paramshash (timeouts, proxy, debug output). It has been open since April 2025.This proposal is deliberately narrower: just the two timeouts, as typed
Contextsettings. That keeps the change small and easy to review, and doesn't commit the gem to exposing all of HTTParty's options. If maintainers prefer the general approach in #1376, that covers this too.