{"record":{"id":"6268ec00f84a2235","repo":"unslothai/unsloth","slug":"memory-cleanup-failed-see-server-logs-for-details","errorCode":null,"errorMessage":"Memory cleanup failed. See server logs for details.","messagePattern":"Memory cleanup failed\\. See server logs for details\\.","errorType":"http","errorClass":"HTTPException","httpStatus":500,"severity":"error","filePath":"studio/backend/routes/export.py","lineNumber":131,"sourceCode":"        if isinstance(e, SidecarSwapInProgress):\n            # Expected loss of the race against a sidecar install: retryable 409.\n            raise HTTPException(status_code = 409, detail = str(e))\n        logger.error(f\"Error loading checkpoint: {e}\", exc_info = True)\n        raise HTTPException(\n            status_code = 500,\n            detail = \"Failed to load checkpoint\",\n        )\n\n\n@router.post(\"/cleanup\", response_model = ExportOperationResponse)\nasync def cleanup_export_memory(current_subject: str = Depends(get_current_subject)):\n    \"\"\"Cleanup export-related models from memory (ExportBackend.cleanup_memory).\"\"\"\n    try:\n        backend = get_export_backend()\n        success = await asyncio.to_thread(backend.cleanup_memory)\n\n        if not success:\n            raise HTTPException(\n                status_code = 500,\n                detail = \"Memory cleanup failed. See server logs for details.\",\n            )\n\n        return ExportOperationResponse(\n            success = True,\n            message = \"Memory cleanup completed successfully\",\n        )\n    except HTTPException:\n        raise\n    except Exception as e:\n        logger.error(f\"Error during export memory cleanup: {e}\", exc_info = True)\n        raise HTTPException(\n            status_code = 500,\n            detail = \"Failed to cleanup export memory\",\n        )\n\n","sourceCodeStart":113,"sourceCodeEnd":149,"githubUrl":"https://github.com/unslothai/unsloth/blob/203007d19051dcd2ae33876786d117c99f6b0368/studio/backend/routes/export.py#L113-L149","documentation":"HTTP 500 raised when ExportBackend.cleanup_memory completes but returns success=False — the backend ran, decided it could not free resources, and reported failure. The detail points to server logs because the reason (e.g. a worker refusing to release a model) is logged by the backend, not returned.","triggerScenarios":"POST /export/cleanup while a model is pinned by an active export/training subprocess, or when the cleanup routine internally catches an error and returns False instead of raising.","commonSituations":"Trying to free memory mid-export; a stuck worker subprocess holding references; platform differences in the cleanup path.","solutions":["Check server logs around the cleanup call for the backend's reason.","Cancel any active export first (POST /export/cancel), then retry cleanup.","If a worker subprocess is stuck, restart the backend process to force-release VRAM."],"exampleFix":null,"handlingStrategy":"try-catch","validationCode":"const st = await api.get('/export/status');\nif (st.is_export_active) await api.post('/export/cancel');","typeGuard":null,"tryCatchPattern":"try {\n  await api.post('/export/cleanup');\n} catch (e) {\n  if (e.status === 500) log('cleanup refused; check server logs');\n}","preventionTips":["Cancel active exports before cleanup.","Treat cleanup failure as non-fatal; it rarely blocks the next load."],"tags":["export","memory","http-500","cleanup"],"backgroundTag":null,"analyzedSha":"203007d19051dcd2ae33876786d117c99f6b0368","analyzedAt":"2026-08-15T02:48:39.846Z","schemaVersion":2},"datasetVersion":"2026-08-15T22:17:37.221Z"}