Improve worker error logging and update Dokploy deployment docs
Some checks failed
Deploy MineGeo to Dokploy / deploy (push) Has been cancelled

This commit is contained in:
2026-10-16 09:37:57 +05:00
parent 1f254b29a2
commit c9fc9496eb
3 changed files with 21 additions and 10 deletions

View File

@@ -30,6 +30,17 @@ function check<T>(r: {
if (r.error) throw new Error(r.error.message);
return r.data!;
}
function summarizeWorkerError(error: unknown) {
const message = (error instanceof Error ? error.message : String(error))
.replace(/\s+/g, " ")
.trim();
if (/<(?:!doctype|html|head|body)\b/i.test(message)) {
const status = message.match(/\b([45]\d{2})\b/)?.[1];
const provider = /cloudflare/i.test(message) ? "Cloudflare" : "upstream";
return `${provider} returned an HTML error${status ? ` (${status})` : ""}`;
}
return message.length > 500 ? `${message.slice(0, 497)}…` : message;
}
async function processJob(job: {
id: string;
dataset_id: string;
@@ -427,7 +438,9 @@ while (!stopping) {
if (jobs?.length) await processJob(jobs[0]);
else await new Promise((r) => setTimeout(r, 2500));
} catch (error) {
console.error("Worker:", error instanceof Error ? error.message : error);
console.error(
`Worker error (retrying in 5s): ${summarizeWorkerError(error)}`,
);
await new Promise((r) => setTimeout(r, 5000));
}
}