fix: make property-assessor safer for whatsapp runs

This commit is contained in:
2026-03-28 01:28:59 -05:00
parent 2deeb31369
commit 3d7ce7617c
15 changed files with 640 additions and 217 deletions

View File

@@ -1,7 +1,7 @@
import test from "node:test";
import assert from "node:assert/strict";
import { normalizeImageCandidates } from "./real-estate-photo-common.js";
import { normalizeImageCandidates, runWithOperationTimeout } from "./real-estate-photo-common.js";
test("normalizeImageCandidates keeps distinct Zillow photo URLs and strips query strings", () => {
const result = normalizeImageCandidates(
@@ -64,3 +64,24 @@ test("normalizeImageCandidates filters tiny HAR page assets and keeps large phot
"https://photos.har.com/123/main.jpg",
]);
});
test("runWithOperationTimeout rejects stalled work and runs timeout cleanup", async () => {
let cleanedUp = false;
await assert.rejects(
async () =>
runWithOperationTimeout(
"HAR photo extraction",
async () => await new Promise(() => {}),
{
timeoutMs: 20,
onTimeout: async () => {
cleanedUp = true;
},
}
),
/timed out/i
);
assert.equal(cleanedUp, true);
});