[object Object]

← back to Dw Add Sellable Variant Tk10902

TK-10456: harden activate-cohort gql() with retry (EHOSTUNREACH crashed batch mid-run)

b0d86e13751e08a33debef1a8cea0924fd3bd55c · 2026-08-31 14:47:55 -0700 · Steve Abrams

Files touched

Diff

commit b0d86e13751e08a33debef1a8cea0924fd3bd55c
Author: Steve Abrams <steve@designerwallcoverings.com>
Date:   Mon Aug 31 14:47:55 2026 -0700

    TK-10456: harden activate-cohort gql() with retry (EHOSTUNREACH crashed batch mid-run)
---
 activate-cohort.mjs | 13 +++++++++----
 1 file changed, 9 insertions(+), 4 deletions(-)

diff --git a/activate-cohort.mjs b/activate-cohort.mjs
index 43754e7..15d0319 100644
--- a/activate-cohort.mjs
+++ b/activate-cohort.mjs
@@ -33,10 +33,15 @@ async function rest(path, method = 'GET', body = null) {
   return { status: 0, json: {} };
 }
 async function gql(query, variables) {
-  const res = await fetch(`https://${DOMAIN}/admin/api/2024-10/graphql.json`, {
-    method: 'POST', headers: { 'X-Shopify-Access-Token': TOKEN, 'Content-Type': 'application/json' },
-    body: JSON.stringify({ query, variables }) });
-  return res.json().catch(() => ({}));
+  for (let i = 0; i < 4; i++) {
+    try {
+      const res = await fetch(`https://${DOMAIN}/admin/api/2024-10/graphql.json`, {
+        method: 'POST', headers: { 'X-Shopify-Access-Token': TOKEN, 'Content-Type': 'application/json' },
+        body: JSON.stringify({ query, variables }) });
+      return await res.json().catch(() => ({}));
+    } catch (e) { await new Promise(r => setTimeout(r, 2500)); }
+  }
+  return {}; // network kept failing — treat as publish-unconfirmed, don't crash the run
 }
 const appendJsonl = (p, o) => fs.appendFileSync(p, JSON.stringify(o) + '\n');
 

← 635c34e auto-data-snapshot: 2026-08-31T14:28:57 (6 data files) — act  ·  back to Dw Add Sellable Variant Tk10902  ·  TK-10456: activation complete — 788/788 cohort products live e71cfd0 →