← back to All Designerwallcoverings
auto-save: 2026-07-27T14:51:27 (1 files) — server.js
ae33f6da85903d523e7db9dd6ec52e05f511aabd · 2026-07-27 14:51:28 -0700 · Steve Abrams
Files touched
Diff
commit ae33f6da85903d523e7db9dd6ec52e05f511aabd
Author: Steve Abrams <steve@designerwallcoverings.com>
Date: Mon Jul 27 14:51:28 2026 -0700
auto-save: 2026-07-27T14:51:27 (1 files) — server.js
---
server.js | 11 ++++++++---
1 file changed, 8 insertions(+), 3 deletions(-)
diff --git a/server.js b/server.js
index 1c8505b..d1e310d 100644
--- a/server.js
+++ b/server.js
@@ -1104,7 +1104,7 @@ async function handleLiveStock(req, res, u) {
// cache: repeat within the 10-min window returns the cached live result, $0.
// (Applies to BOTH tiers and BOTH initiate + poll — a fresh cache hit is always "done".)
const hit = liveCache.get(key);
- if (hit && (Date.now() - hit.at) < LIVE_CACHE_MS) {
+ if (hit && (Date.now() - hit.at) < (hit.ttl || LIVE_CACHE_MS)) {
return sendJSON(res, 200, { ...hit.result, status: 'done', cached: true, cost_usd: 0, cache_age_s: Math.round((Date.now() - hit.at) / 1000) });
}
@@ -1193,11 +1193,16 @@ async function handleLiveStock(req, res, u) {
.then((r) => {
if (r.cost_usd > 0) addDaySpend(r.cost_usd);
r.day_spend_usd = +daySpendUSD().toFixed(4); r.day_cap_usd = DAILY_LIVE_CAP_USD;
- liveCache.set(key, { result: { ...r, status: 'done' }, at: Date.now() });
+ // Cache a real answer (ok, incl. a genuine negative availability) for the full window;
+ // a TRANSIENT failure (timeout / worker error, !ok) only briefly — so the in-flight poll
+ // still renders its specific reason, but the SKU is NOT retry-locked for 10 min (the bug a
+ // blanket cache-of-failure would create — contrarian-gated 2026-07-27; matches the DB
+ // tier's success-only rule at ~line 1143).
+ liveCache.set(key, { result: { ...r, status: 'done' }, at: Date.now(), ttl: r.ok ? LIVE_CACHE_MS : 30 * 1000 });
return r;
})
.catch((e) => {
- liveCache.set(key, { result: { ok: false, live: true, live_available: true, sku, reason: 'live scrape error: ' + e.message, cost_usd: 0, status: 'done' }, at: Date.now() });
+ liveCache.set(key, { result: { ok: false, live: true, live_available: true, sku, reason: 'live scrape error: ' + e.message, cost_usd: 0, status: 'done' }, at: Date.now(), ttl: 30 * 1000 });
})
.finally(() => { liveInflight.delete(key); });
liveInflight.set(key, p);
← 76b0372 all.dw: raise live-scrape worker timeout 52s->75s (async/pol
·
back to All Designerwallcoverings
·
astek CF-Access: env-gated service-token headers on crawler 26c4bba →