unslothai/unsloth · error · HTTPException
Failed to cleanup export memory
Error message
Failed to cleanup export memory
What it means
Catch-all HTTP 500 for the cleanup endpoint: cleanup_memory raised an unexpected exception (rather than returning False). The traceback is logged as 'Error during export memory cleanup'; the client only sees the generic message.
Source
Thrown at studio/backend/routes/export.py:144
try:
backend = get_export_backend()
success = await asyncio.to_thread(backend.cleanup_memory)
if not success:
raise HTTPException(
status_code = 500,
detail = "Memory cleanup failed. See server logs for details.",
)
return ExportOperationResponse(
success = True,
message = "Memory cleanup completed successfully",
)
except HTTPException:
raise
except Exception as e:
logger.error(f"Error during export memory cleanup: {e}", exc_info = True)
raise HTTPException(
status_code = 500,
detail = "Failed to cleanup export memory",
)
@router.post("/cancel", response_model = ExportOperationResponse)
async def cancel_export(current_subject: str = Depends(get_current_subject)):
"""Cancel the in-flight export by terminating its worker subprocess.
Only the export subprocess is killed; training and inference run in their
own subprocesses and keep going.
"""
try:
backend = get_export_backend()
cancelled = await asyncio.to_thread(backend.cancel_export)
return ExportOperationResponse(
success = True,
message = "Export cancelled" if cancelled else "No active export to cancel",View on GitHub (pinned to 203007d190)
Solutions
- Read the server log traceback for 'Error during export memory cleanup'.
- If the worker subprocess died, restart the backend rather than retrying cleanup against a dead IPC channel.
- Treat cleanup as best-effort in clients: a 500 here usually does not block subsequent loads.
Defensive patterns
Strategy: try-catch
Try / catch
try {
await api.post('/export/cleanup');
} catch (e) {
if (e.status === 500) { /* best-effort; check backend logs */ }
} Prevention
- Do not call cleanup against a crashed worker — restart the backend instead.
- Make cleanup idempotent and non-blocking in client flows.
When it happens
Trigger: POST /export/cleanup when get_export_backend() or backend.cleanup_memory throws — e.g. backend not initialized, IPC to the worker failing because the worker already died, or an environment with no accelerator library present.
Common situations: Calling cleanup after the worker crashed; calling it on a fresh backend before any checkpoint was loaded; driver/library mismatch raising inside the memory-free helper.
Related errors
- Memory cleanup failed. See server logs for details.
- Failed to load checkpoint
- Failed to cancel export
- Failed to get export status
- Failed to get export logs
AI-assisted analysis of unslothai/unsloth@203007d190 (2026-08-15).
Data as JSON: /api/errors/94adb75996dc855f.
Report an issue: GitHub.