← back to York Reprice 2026 08
york-cadence: connect PG over /tmp socket instead of TCP 127.0.0.1 (fixes transient connection-refused crash)
9120fee4c95a4f8f9be135763117450ec6fb833f · 2026-08-25 11:57:03 -0700 · Steve Abrams
Co-Authored-By: Claude Opus 4.8 (1M context) <noreply@anthropic.com>
Files touched
M cadence/york-cadence.mjs
Diff
commit 9120fee4c95a4f8f9be135763117450ec6fb833f
Author: Steve Abrams <steve@designerwallcoverings.com>
Date: Tue Aug 25 11:57:03 2026 -0700
york-cadence: connect PG over /tmp socket instead of TCP 127.0.0.1 (fixes transient connection-refused crash)
Co-Authored-By: Claude Opus 4.8 (1M context) <noreply@anthropic.com>
---
cadence/york-cadence.mjs | 8 ++++++--
1 file changed, 6 insertions(+), 2 deletions(-)
diff --git a/cadence/york-cadence.mjs b/cadence/york-cadence.mjs
index b3fc149..a27b787 100644
--- a/cadence/york-cadence.mjs
+++ b/cadence/york-cadence.mjs
@@ -16,12 +16,16 @@ const NO_WRITE=process.env.YORK_CADENCE_NO_WRITE==='1'; // read-only test mode:
const SHOP='designer-laboratory-sandbox.myshopify.com',VER='2024-10';
const TOKEN=(fs.readFileSync(process.env.HOME+'/Projects/secrets-manager/.env','utf8').match(/^SHOPIFY_ADMIN_TOKEN=(.+)$/m)||[])[1]?.trim();
const URL=`https://${SHOP}/admin/api/${VER}/graphql.json`;
-const PG='PGPASSWORD=DW2024! /opt/homebrew/opt/postgresql@14/bin/psql -h 127.0.0.1 -U dw_admin -d dw_unified -tA -F\'\x1f\' -c';
+// Connect over the /tmp UNIX socket (DW-standard canonical dw_unified path) instead of TCP
+// 127.0.0.1:5432. TCP 5432's listener flaps transiently (it went down Aug 15 → uncaught execSync
+// throw → cadence crash); the /tmp socket is always present. Keep -U dw_admin (md5/scram over the
+// socket authenticates cleanly on this box's pg_hba — least behavior change).
+const PG='PGPASSWORD=DW2024! /opt/homebrew/opt/postgresql@14/bin/psql -h /tmp -U dw_admin -d dw_unified -tA -F\'\x1f\' -c';
// multi-line SQL breaks `psql -c "<sql>"` ("invalid command \n") — the onboardCand query is
// multi-line and was silently throwing into a catch{}, falsely returning onboardReady=0 for
// MONTHS. Route every query through a temp .sql file + `-f` so multi-line SQL is safe.
// (All cadence queries concat_ws(chr(31),…) into ONE column, so -F is unnecessary.)
-const q=sql=>{fs.writeFileSync('/tmp/_yc_q.sql',sql);return execSync(`PGPASSWORD=DW2024! /opt/homebrew/opt/postgresql@14/bin/psql -h 127.0.0.1 -U dw_admin -d dw_unified -tA -f /tmp/_yc_q.sql`,{encoding:'utf8'}).trim();};
+const q=sql=>{fs.writeFileSync('/tmp/_yc_q.sql',sql);return execSync(`PGPASSWORD=DW2024! /opt/homebrew/opt/postgresql@14/bin/psql -h /tmp -U dw_admin -d dw_unified -tA -f /tmp/_yc_q.sql`,{encoding:'utf8'}).trim();};
const sleep=ms=>new Promise(r=>setTimeout(r,ms));
const gql=async(query,v)=>{for(let a=0;a<8;a++){let j;try{const r=await fetch(URL,{method:'POST',headers:{'X-Shopify-Access-Token':TOKEN,'Content-Type':'application/json'},body:JSON.stringify({query,variables:v})});j=await r.json();}catch(e){await sleep(1500*(a+1));continue;}if(j.errors){if(JSON.stringify(j.errors).includes('THROTTLED')){await sleep(2000*(a+1));continue;}throw new Error(JSON.stringify(j.errors));}const t=j.extensions?.cost?.throttleStatus;if(t&&t.currentlyAvailable<300)await sleep(1500);return j.data;}throw new Error('retries');};
const norm=s=>String(s||'').toUpperCase().trim();
← 807f76a auto-data-snapshot: 2026-08-15T01:35:55 (1 data files) — cad
·
back to York Reprice 2026 08
·
york-cadence: remove dead PG const (unused; q() is the only b2c0e8f →