dot-lookup: revert fmcsaFetch wrapping (already null-safe), keep 5s SOS timeout

The bare catch{} introduced a control-flow issue. fmcsaFetch() already returns
null on all errors and never throws, so the try/catch wrapping was unnecessary.
Keep only the SOS timeout reduction (20s->5s) as the actual fix for the nginx
proxy timeout that caused 'Failed to fetch' on slow DOT lookups.

Co-Authored-By: Claude Sonnet 4.6 <noreply@anthropic.com>
This commit is contained in:
justin 2026-05-31 10:28:59 -05:00
parent e0be6468d4
commit e7afc3002e

View file

@ -66,23 +66,13 @@ router.get("/api/v1/dot/lookup", async (req, res) => {
);
const census = local.rows[0] || null;
// 2. Live FMCSA API — wrapped so a timeout or outage still returns census data
let carrier: any = null;
try {
const snapshot = await fmcsaFetch(rawDot);
carrier = snapshot?.content?.carrier || null;
} catch {
// FMCSA live API unavailable — continue with local census data
}
// 2. Live FMCSA API (returns null on any failure — already non-throwing)
const snapshot = await fmcsaFetch(rawDot);
const carrier = snapshot?.content?.carrier || null;
// 3. Authority check — also non-fatal
let authorities: any[] = [];
try {
const authorityData = await fmcsaFetch(`${rawDot}/authority`);
authorities = (authorityData?.content || []).map((a: any) => a.carrierAuthority);
} catch {
// Authority lookup failed — skip, checks will use census data where possible
}
// 3. Authority check
const authorityData = await fmcsaFetch(`${rawDot}/authority`);
const authorities = (authorityData?.content || []).map((a: any) => a.carrierAuthority);
if (!census && !carrier) {
res.status(404).json({ error: `DOT# ${rawDot} not found.` });