From e66c0ebec1583e204b50826165d06610c6034151 Mon Sep 17 00:00:00 2001 From: "Brennan Wilkes (Text Groove)" Date: Thu, 29 Jan 2026 12:18:09 -0800 Subject: [PATCH] fix: FInal cOop adjustments --- src/stores/coop.js | 47 +++++++++++++++++++++--------------------- src/tracker/merge.js | 25 ++++++++++++++++------ viz/app/linker_page.js | 23 ++++++++++++++------- 3 files changed, 58 insertions(+), 37 deletions(-) diff --git a/src/stores/coop.js b/src/stores/coop.js index 6c45a01..6687e53 100644 --- a/src/stores/coop.js +++ b/src/stores/coop.js @@ -54,13 +54,12 @@ function coopHeaders(ctx, sourcepage) { }; } -async function fetchText(url, { headers, ua } = {}) { - const h = { ...(headers || {}) }; - if (ua) h["User-Agent"] = ua; - const res = await fetch(url, { method: "GET", headers: h }); - const text = await res.text(); - return { status: res.status, text }; - } +async function coopFetchText(ctx, url, label, { headers } = {}) { + return await ctx.http.fetchTextWithRetry(url, label, ctx.store.ua, { + method: "GET", + headers: headers || {}, + }); +} function extractVar(html, re) { const m = String(html || "").match(re); @@ -71,24 +70,24 @@ async function fetchText(url, { headers, ua } = {}) { const coop = ctx.store.coop; if (coop.sessionKey && coop.chainId && coop.storeId && coop.appVersion) return; - const r = await fetchText(REFERER, { - ua: ctx.store.ua, - headers: { - Accept: "text/html,application/xhtml+xml,application/xml;q=0.9,*/*;q=0.8", - Referer: REFERER, - }, - }); - - if (r.status !== 200 || !r.text) { - throw new Error(`coop bootstrap failed: GET ${REFERER} => ${r.status}`); +const r = await coopFetchText(ctx, REFERER, "coop:bootstrap", { + headers: { + Accept: "text/html,application/xhtml+xml,application/xml;q=0.9,*/*;q=0.8", + Referer: REFERER, + }, + }); + + const html = r?.text || ""; + if (r?.status !== 200 || !html) { + throw new Error(`coop bootstrap failed: GET ${REFERER} => ${r.status}`); } // Values are in