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:
@@ -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;
|
||||
}
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user