feat: add 5s timeout and warning log for station name search (refs #141)

Add 5000ms timeout to Places Text Search API call in searchStationByName.
Timeout errors log a warning instead of error and return null gracefully.
Add timeout test case to station-matching unit tests.

Co-Authored-By: Claude Opus 4.6 <noreply@anthropic.com>
This commit is contained in:
Eric Gullickson
2026-02-11 13:03:35 -06:00
parent c79b610145
commit 4e5da4782f
2 changed files with 25 additions and 2 deletions

View File

@@ -128,6 +128,7 @@ export class GoogleMapsClient {
type: 'gas_station',
key: this.apiKey,
},
timeout: 5000,
}
);
@@ -145,8 +146,12 @@ export class GoogleMapsClient {
await cacheService.set(cacheKey, station, this.cacheTTL);
return station;
} catch (error) {
logger.error('Station name search failed', { error, merchantName });
} catch (error: any) {
if (error.code === 'ECONNABORTED' || error.message?.includes('timeout')) {
logger.warn('Station name search timed out', { merchantName, timeoutMs: 5000 });
} else {
logger.error('Station name search failed', { error, merchantName });
}
return null;
}
}