Forgot a Timeout <3

This commit is contained in:
2026-02-28 16:45:21 +11:00
parent 38cdc156d6
commit c88ddef2f9
+10 -1
View File
@@ -1854,12 +1854,16 @@ const romanizeLinePayload = async (
]; ];
for (const url of urls) { for (const url of urls) {
const controller = new AbortController();
const timeout = setTimeout(() => controller.abort(), 5000);
try { try {
const res = await fetch(url, { const res = await fetch(url, {
method: "POST", method: "POST",
headers: { "content-type": "application/json" }, headers: { "content-type": "application/json" },
body: JSON.stringify(payload), body: JSON.stringify(payload),
signal: controller.signal,
}); });
clearTimeout(timeout);
if (!res.ok) { if (!res.ok) {
trace.log(`Romanize: request failed ${res.status} from ${url}`); trace.log(`Romanize: request failed ${res.status} from ${url}`);
continue; continue;
@@ -1879,7 +1883,12 @@ const romanizeLinePayload = async (
cachedTidalRomanizedLines = romanized; cachedTidalRomanizedLines = romanized;
return romanized; return romanized;
} catch (err) { } catch (err) {
trace.log(`Romanize: request error from ${url}: ${err}`); clearTimeout(timeout);
if (err instanceof DOMException && err.name === "AbortError") {
trace.log(`Romanize: request timed out from ${url}`);
} else {
trace.log(`Romanize: request error from ${url}: ${err}`);
}
} }
} }