Fix slower Zillow unit photo discovery path

This commit is contained in:
2026-03-28 02:28:30 -05:00
parent 7690dc259b
commit 8fe451e8d0
11 changed files with 167 additions and 49 deletions

View File

@@ -22,6 +22,8 @@ export interface PhotoReviewResolution {
interface PhotoReviewDeps {
timeoutMs?: number;
zillowTimeoutMs?: number;
harTimeoutMs?: number;
extractZillowPhotosFn?: typeof extractZillowPhotos;
extractHarPhotosFn?: typeof extractHarPhotos;
}
@@ -29,6 +31,12 @@ interface PhotoReviewDeps {
const DEFAULT_PHOTO_EXTRACTION_TIMEOUT_MS = Number(
process.env.PROPERTY_ASSESSOR_PHOTO_TIMEOUT_MS || 25_000
);
const DEFAULT_ZILLOW_PHOTO_EXTRACTION_TIMEOUT_MS = Number(
process.env.PROPERTY_ASSESSOR_ZILLOW_PHOTO_TIMEOUT_MS || 60_000
);
const DEFAULT_HAR_PHOTO_EXTRACTION_TIMEOUT_MS = Number(
process.env.PROPERTY_ASSESSOR_HAR_PHOTO_TIMEOUT_MS || DEFAULT_PHOTO_EXTRACTION_TIMEOUT_MS
);
export async function extractPhotoData(
source: PhotoSource,
@@ -36,15 +44,21 @@ export async function extractPhotoData(
deps: PhotoReviewDeps = {}
): Promise<PhotoExtractionResult> {
const timeoutMs = deps.timeoutMs ?? DEFAULT_PHOTO_EXTRACTION_TIMEOUT_MS;
const zillowTimeoutMs =
deps.zillowTimeoutMs ??
(deps.timeoutMs != null ? timeoutMs : DEFAULT_ZILLOW_PHOTO_EXTRACTION_TIMEOUT_MS);
const harTimeoutMs =
deps.harTimeoutMs ??
(deps.timeoutMs != null ? timeoutMs : DEFAULT_HAR_PHOTO_EXTRACTION_TIMEOUT_MS);
const extractZillowPhotosFn = deps.extractZillowPhotosFn || extractZillowPhotos;
const extractHarPhotosFn = deps.extractHarPhotosFn || extractHarPhotos;
if (source === "zillow") {
const payload = await withTimeout(
() => extractZillowPhotosFn(url),
() => extractZillowPhotosFn(url, { timeoutMs: zillowTimeoutMs }),
{
operationName: "Zillow photo extraction",
timeoutMs
timeoutMs: zillowTimeoutMs
}
);
return {
@@ -60,10 +74,10 @@ export async function extractPhotoData(
}
const payload = await withTimeout(
() => extractHarPhotosFn(url),
() => extractHarPhotosFn(url, { timeoutMs: harTimeoutMs }),
{
operationName: "HAR photo extraction",
timeoutMs
timeoutMs: harTimeoutMs
}
);
return {