Forgot a Timeout <3

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