Mintplex-Labs/anything-llm · error · Error
Failed to download file
Error message
Failed to download file
What it means
GeneratedFileCard streams a scheduled-job artifact via StorageFiles.download(file.storageFilename). If the call returns a falsy blob (missing file, expired signed URL, auth failure) or throws, the catch shows the localized 'download failed' toast. The inner throw new Error('Failed to download file') is the explicit guard for a falsy blob.
Solutions
- Retry once — transient storage/network errors often clear immediately.
- Check the Network tab for the storage file request status: 401 → re-login, 404 → file gone, 500 → storage backend issue.
- Verify the file still exists in the job's storage directory (or bucket) if 404.
- Confirm storage provider credentials/config if downloads consistently fail.
Defensive patterns
Strategy: retry
Validate before calling
function isDownloadable(file) {
return !!file && typeof file.storageFilename === 'string' && file.storageFilename.length > 0;
}
// Before starting:
if (!isDownloadable(file)) { showToast('File is no longer available.', 'warning'); return; } Try / catch
async function downloadArtifact(storageFilename, filename, tries = 2) {
for (let attempt = 1; attempt <= tries; attempt++) {
try {
const blob = await StorageFiles.download(storageFilename);
if (!blob) throw new Error('Empty response');
const { saveAs } = await import('file-saver');
return saveAs(blob, filename || storageFilename);
} catch (e) {
if (attempt === tries) throw e; // transient storage/network errors often clear on retry
await new Promise((r) => setTimeout(r, 500 * attempt));
}
}
} Prevention
- Disable the download button for artifacts older than the retention window, or prune them from the list.
- Keep the jobs page session fresh so storage requests do not 401 after long idle.
- Distinguish 404 (file gone — stop retrying) from 5xx/network (retry once) in the handler.
When it happens
Trigger: Downloading a file whose storageFilename was already removed by retention cleanup; a 401 on the storage route from an expired session; the storage backend (local disk or S3) unreachable; the file deleted between listing job artifacts and clicking download.
Common situations: Old job artifact pruned by cleanup but still listed in the UI; storage driver misconfigured; session token expired while the jobs page stayed open.
Related errors
- File not found in storage
- Cannot create: maximum of
- Cannot enable: maximum of
- Failed to create thread
- Failed to create workspace
AI-assisted analysis of Mintplex-Labs/anything-llm@3aec848f28 (2026-08-18).
Data as JSON: /api/errors/8dd53d34c2eaad0e.
Report an issue: GitHub.
Appendix: source
Thrown at frontend/src/pages/GeneralSettings/ScheduledJobs/components/GeneratedFileCard.jsx:89
return {
...fileDisplayInfo,
type: fileDisplayInfo.label(t),
};
}
// Card representing a file generated by a job run. Streams the file from
// the storage API on download via dynamic import of file-saver.
export default function GeneratedFileCard({ file }) {
const { t } = useTranslation();
const [downloading, setDownloading] = useState(false);
const { badge, bg, text, type } = getFileDisplayInfo(file.filename, t);
const handleDownload = async () => {
if (downloading || !file.storageFilename) return;
setDownloading(true);
try {
const blob = await StorageFiles.download(file.storageFilename);
if (!blob) throw new Error("Failed to download file");
const { saveAs } = await import("file-saver");
saveAs(blob, file.filename || file.storageFilename);
} catch {
showToast(t("scheduledJobs.file.downloadFailed"), "error");
} finally {
setDownloading(false);
}
};
return (
<div className="flex items-center justify-between bg-zinc-800 light:bg-slate-100 rounded-lg p-3">
<div className="flex items-center gap-3 min-w-0">
<div
className={`${bg} ${text} rounded-lg flex items-center justify-center shrink-0 h-10 w-10 text-xs font-semibold`}
>
{badge}
</div>
<div className="flex flex-col min-w-0">View on GitHub (pinned to 3aec848f28)