Modern Apps git

← Modern-Apps.git

shop: stop failing slow searches on the 10s read timeout

Commit
d80685d537d78a779895f123ab1e19f8b3228991
Author
Vayun Mathur <[email protected]>
When
2026-12-02 03:00 UTC (4 days ago)
Parents
ab8cceb
The server holds a /shop/v1/search response until its slowest
source answers: a full search fans out to directory merchants
(8s cap) plus the Shopify Global Catalog, which the server
allows 30s (CALL_TIMEOUT). Cold Global Catalog calls measured
against api.maproj.org took 10.3s and 18.2s to first byte on
roughly one in seven fresh queries (the rest 2-4s), and every
one eventually returned HTTP 200. The client's 10s read
timeout aborted those slow-but-successful searches, surfacing
as Shop failed / Couldn't reach the store.

Raise the read budget to match the server's 30s call budget
and the coroutine cap to 45s so connect + read fit back to
back. Connect stays 10s. Verified: :shop:lint,
:shop:lintVitalRelease and :shop:testDevUnitTest green.

Diff

shop/src/main/java/com/vayunmathur/shop/network/ShopBackend.kt
diff --git a/shop/src/main/java/com/vayunmathur/shop/network/ShopBackend.kt b/shop/src/main/java/com/vayunmathur/shop/network/ShopBackend.ktindex d78058f983..8d8e9d22f4 100644--- a/shop/src/main/java/com/vayunmathur/shop/network/ShopBackend.kt+++ b/shop/src/main/java/com/vayunmathur/shop/network/ShopBackend.kt@@ -80,7 +80,14 @@ internal object ShopHttpBackend : ShopBackend {         url: String,         body: String?,     ) -> BackendRawResponse = { method, url, body ->-        val response = withTimeout(30_000) {+        // The server holds a search response until its slowest source+        // answers: a full search fans out to directory merchants (8s cap)+        // plus the Shopify Global Catalog, which the server allows 30s+        // (CALL_TIMEOUT) and which takes 10-18s on a cold tail. A 10s read+        // timeout aborted those slow-but-successful searches, so the read+        // budget matches the server's 30s call budget and the coroutine+        // cap leaves room for connect + read back to back.+        val response = withTimeout(45_000) {             NetworkClient.execute(                 url, method,                 headers = mapOf(@@ -90,7 +97,7 @@ internal object ShopHttpBackend : ShopBackend {                 body = body,                 followRedirects = false,                 connectTimeoutMs = 10_000,-                readTimeoutMs = 10_000,+                readTimeoutMs = 30_000,             )         }         BackendRawResponse(response.status, response.text, response.headers, response.header("Retry-After"))