← back to Commercialrealestate
broker-email-finder: hard per-broker timeout so a single hung site can't wedge the batch
f93ac06e73e4fa0a22342c05595bcfd6461c07ad · 2026-07-12 11:33:32 -0700 · Steve Abrams
Files touched
M scripts/broker-email-finder.js
Diff
commit f93ac06e73e4fa0a22342c05595bcfd6461c07ad
Author: Steve Abrams <steve@designerwallcoverings.com>
Date: Sun Jul 12 11:33:32 2026 -0700
broker-email-finder: hard per-broker timeout so a single hung site can't wedge the batch
---
scripts/broker-email-finder.js | 8 +++++++-
1 file changed, 7 insertions(+), 1 deletion(-)
diff --git a/scripts/broker-email-finder.js b/scripts/broker-email-finder.js
index bcb8e75..0af7f96 100644
--- a/scripts/broker-email-finder.js
+++ b/scripts/broker-email-finder.js
@@ -68,6 +68,11 @@ const TLD_OK = new Set(('com net org edu gov mil io co us biz info me tv realtor
'estate realestate group team agency partners capital ventures llc inc law cpa dental health ' +
'ca uk au nz de fr es it nl eu global online site pro top xyz live life world today').split(' '));
const sleep = ms => new Promise(r => setTimeout(r, ms));
+// Hard per-broker ceiling — a single site's fetch/body-read can occasionally evade the AbortController
+// (slow-trickle body, keep-alive) and wedge the whole batch. This guarantees the run always advances.
+function withTimeout(promise, ms, onTimeout) {
+ return Promise.race([promise, new Promise(res => setTimeout(() => res(onTimeout()), ms))]);
+}
function validEmail(e) {
if (!e || e.length > 60 || (e.match(/@/g) || []).length !== 1 || JUNK.test(e)) return false;
@@ -204,7 +209,8 @@ async function findForBroker(b) {
console.log(`brokers to scan: ${rows.length} | mode ${COMMIT ? 'COMMIT' : 'DRY (no db write)'}\n`);
let found = 0, wrote = 0;
for (const b of rows) {
- const r = await findForBroker(b);
+ const cap = USE_BROWSER ? 75000 : 45000; // browser tier legitimately needs longer
+ const r = await withTimeout(findForBroker(b), cap, () => ({ id: b.id, name: b.name, website: b.website, domain: siteDomain(b.website), found: null, basis: 'timeout', all: [], tried: [{ status: 'HANG>cap' }] }));
if (r.found) {
found++;
console.log(`✓ ${r.name} (#${r.id}) [${r.basis}]`);
← db7a5da Serve col-resize.js via dedicated no-cache route (revalidate
·
back to Commercialrealestate
·
broker-email: poison-guard sole-email on corporate megasite/ beb4036 →