Skip to content

Commit a637c27

Browse files
ageem23luisjo88claude
committed
fix(scan): isolate detect() exceptions and surface unknown-provider count
- Wrap detect() in try/catch inside resolveProvider so a buggy community provider can't crash the entire scan (R1). Mirrors the catch-and-skip pattern the loader already applies to failed provider imports. - Append unknown-provider count to the scan summary line so the totals reconcile when a tracked_companies entry references a non-loaded provider id (R2). Closes an accounting gap the refactor itself introduced. R3 (AbortError → "timed out after Xms") deferred to a follow-up hardening PR — pre-refactor fetchJson surfaced AbortError the same opaque way, so it's a behavior improvement rather than a refactor. Refs: santifer#521, santifer#599 Co-Authored-By: Luis Johan <luis.j.lithgow@gmail.com> Co-Authored-By: Claude Opus 4.7 (1M context) <noreply@anthropic.com>
1 parent 35ded27 commit a637c27

1 file changed

Lines changed: 9 additions & 3 deletions

File tree

scan.mjs

Lines changed: 9 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -89,8 +89,12 @@ function resolveProvider(entry, providers) {
8989
return { provider: p };
9090
}
9191
for (const p of providers.values()) {
92-
const hit = p.detect?.(entry);
93-
if (hit) return { provider: p };
92+
try {
93+
const hit = p.detect?.(entry);
94+
if (hit) return { provider: p };
95+
} catch (e) {
96+
console.warn(`[warn] provider ${p.id} detect() threw: ${e.message}`);
97+
}
9498
}
9599
return null;
96100
}
@@ -260,7 +264,9 @@ async function main() {
260264
targets.push({ ...company, _provider: resolved.provider });
261265
}
262266

263-
console.log(`Scanning ${targets.length} companies via providers (${skippedCount} skipped — no provider matched)`);
267+
const resolveErrCount = resolveErrors.length;
268+
const skipSuffix = resolveErrCount ? `, ${resolveErrCount} unknown provider` : '';
269+
console.log(`Scanning ${targets.length} companies via providers (${skippedCount} skipped — no provider matched${skipSuffix})`);
264270
if (dryRun) console.log('(dry run — no files will be written)\n');
265271

266272
// 4. Load dedup sets

0 commit comments

Comments
 (0)