Resolve stale failure stuck on import

This commit is contained in:
2026-05-16 16:23:15 -03:00
parent b70ac9bc6f
commit 636d3b73cb
2 changed files with 80 additions and 7 deletions
+29 -5
View File
@@ -274,16 +274,40 @@
result.className = "inbox-action-result is-error";
result.textContent = job.error || "Processing failed.";
renderDuplicateReports(inboxId, []);
progress.classList.remove("is-active", "is-indeterminate");
fill.style.width = "0%";
}
return running;
};
const pollJob = async (jobId, inboxId) => {
const response = await fetch(`/api/admin/import-jobs/${jobId}`, { credentials: "same-origin" });
const job = await response.json();
if (renderJob(job, inboxId)) {
window.setTimeout(() => pollJob(jobId, inboxId), 2000);
} else {
try {
const response = await fetch(`/api/admin/import-jobs/${jobId}`, { credentials: "same-origin" });
if (!response.ok) {
throw new Error("Import job status is unavailable.");
}
const job = await response.json();
if (renderJob(job, inboxId)) {
window.setTimeout(() => pollJob(jobId, inboxId), 2000);
} else {
renderInboxStatus(inboxId);
}
} catch (error) {
const result = document.getElementById(`inbox-action-result-${inboxId}`);
const progress = document.getElementById(`inbox-progress-${inboxId}`);
const fill = progress?.querySelector("span");
const buttons = document.querySelectorAll(`.js-inbox-action[data-inbox-id="${inboxId}"]`);
buttons.forEach((button) => { button.disabled = false; });
if (progress) {
progress.classList.remove("is-active", "is-indeterminate");
}
if (fill) {
fill.style.width = "0%";
}
if (result) {
result.className = "inbox-action-result is-error";
result.textContent = error.message || "Import job status is unavailable.";
}
renderInboxStatus(inboxId);
}
};